You should be able to use that json by doing something like:

- debug: msg="{{ (result.stdout|from_json).ipaddress }}"

If you wanted to try to turn the whole thing into an accessible data type, you 
could probably use set_fact:

- set_fact:
    some_new_var: "{{ result.stdout|from_json }}"

-- 
Matt Martz
[email protected]

On March 21, 2014 at 12:10:26 AM, Jinsik Kim ([email protected]) wrote:

Hi,

I am a newbie in this wonderful tool Ansible.
I made a playbook script to test it.

But I found that sometimes I need to parse the stdout of each task.

For instance

 - name : run and get the result in JSON format on stdout
   shell : "/usr/local/something"
   register : result


Let's see result.stdout

 {u'name':u'test1', u'ipaddress':'xxx.xxx.xxx.xx', u'pass':'asdfasfd'}

Can I extract these three elements(name, ipaddress, pass) from stdout and use 
it on another task?

I think lot of users experienced this issue because the return values(stdout) 
of tools are not simple sometimes

Even if I have a plan to make another Module I think it's tough because I 
should pass the three elements.
(Unfortunately I am not good at Python yet)


Thanks in advance!

-Justin

--
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/0fff3282-8c63-41e2-83d5-297df7f85642%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/etPan.532c30a3.3d1b58ba.11a12%40mobiletuvix.rackspace.corp.
For more options, visit https://groups.google.com/d/optout.

Reply via email to