You can use some thing like this.
- set_fact:
Name: (result.stdout | from_json).name
Ipaddress: similar to the above
On Tue, May 7, 2019 at 2:44 AM Aviya Singh <[email protected]> wrote:
> Hi,
>
> This was helpful.
>
> Meanwhile, I am trying to extract "PRETTY NAME" in a loop from below
> output. What should I use?
>
> [image: snip3.PNG]
>
>
> Can you look into this ?
>
>
> On Wednesday, March 19, 2014 at 10:17:35 AM UTC+5:30, Jinsik Kim 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/0e165dde-e93a-43bf-a62f-a1a4c0a9821d%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/0e165dde-e93a-43bf-a62f-a1a4c0a9821d%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> 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/CAPntZFv3kw_1QWEjg0-BstdWVRmPGFbzs3zTKAVGxiPFQ5NL%2BQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.