# get the value of Json vars ansible

**URL:** <https://forum.ansible.com/t/get-the-value-of-json-vars-ansible/26910>\
**Category:** Ansible Project\
**Created:** [March 6, 2018, 2:09pm UTC](https://forum.ansible.com/t/get-the-value-of-json-vars-ansible/26910 "2018-03-06T14:09:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Brunet\_Julien](https://avatars.discourse-cdn.com/v4/letter/b/0ea827/32.png) [@Brunet\_Julien](https://forum.ansible.com/u/Brunet_Julien)\
**Post date:** [March 6, 2018, 2:09pm UTC](https://forum.ansible.com/t/get-the-value-of-json-vars-ansible/26910/1 "2018-03-06T14:09:59Z")

</div>

**Hello**

**I faced a issue with items , i would like to get the value of Json vars.**  
**But i can’t access/get the value.**

**I write this ansible script :**

`

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [March 6, 2018, 7:06pm UTC](https://forum.ansible.com/t/get-the-value-of-json-vars-ansible/26910/2 "2018-03-06T19:06:36Z")

</div>

> \*Hello \*
> 
> \*I faced a issue with items , i would like to get the value of Json vars.\*  
> \*But i can't access/get the value.\*
> 
> \*I write this ansible script :\*
> 
> ---  
> # tasks file for ansible-f5
> 
> - name: Define f5\_environment vars  
> &nbsp;&nbsp;set\_fact:  
> &nbsp;&nbsp;&nbsp;&nbsp;env\_f5: "QLF"
> 
> - name: Collect BIG-IP facts  
> &nbsp;&nbsp;bigip\_facts:  
> &nbsp;&nbsp;&nbsp;&nbsp;server: "{{f5\_infos[env\_f5].bigip\_server}}"  
> &nbsp;&nbsp;&nbsp;&nbsp;user: "{{f5\_infos[env\_f5].bigip\_user}}"  
> &nbsp;&nbsp;&nbsp;&nbsp;password: "{{f5\_infos[env\_f5].bigip\_password}}"  
> &nbsp;&nbsp;&nbsp;&nbsp;include: node  
> &nbsp;&nbsp;&nbsp;&nbsp;validate\_certs: "false"  
> &nbsp;&nbsp;connection: local  
> &nbsp;&nbsp;register: bigip\_fact\_out  
> &nbsp;&nbsp;#delegate\_to: localhost
> 
> - debug: var=bigip\_fact\_out
> 
> - name: Debug Msg Node  
> &nbsp;&nbsp;debug:  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;msg: "I have : {{ node['/Common/10.70.40.74'].address }} : {{  
> node['/Common/10.70.40.74'].monitor\_status }} : {{  
> node['/Common/10.70.40.74'].session\_status }}"
> 
> - name: Printing Node Item  
> &nbsp;&nbsp;shell: |  
> &nbsp;&nbsp;&nbsp;&nbsp;#\> /tmp/test  
> &nbsp;&nbsp;&nbsp;&nbsp;echo "{{ item.address }}" | sed -e "s/\/Common\///g" \>\> /tmp/test  
> &nbsp;&nbsp;with\_items: "{{node}}"
> 
> \*i would like to get the list of address IP , {{ node[i].address }} where  
> i means the loop items.\*

\<snip\>

> \*if i can store/get the field "address": for each item in the file  
> /tmp/test it would be great .....\*

I don't know where you get node variable from, but the node in bigip\_fact\_out is dictonary and not a list so you can do this

- copy:  
&nbsp;&nbsp;&nbsp;&nbsp;dest: /tmp/test  
&nbsp;&nbsp;&nbsp;&nbsp;content: |  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{% for key, value in bigip\_fact\_out.ansible\_facts.node | dictsort %}  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{{ value.address }}  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{% endfor %}
