On Tuesday, 6 March 2018 15.09.59 CET Brunet Julien wrote:
> *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
>   set_fact:
>     env_f5: "QLF"
> 
> 
> - name: Collect BIG-IP facts
>   bigip_facts:
>     server: "{{f5_infos[env_f5].bigip_server}}"
>     user: "{{f5_infos[env_f5].bigip_user}}"
>     password: "{{f5_infos[env_f5].bigip_password}}"
>     include: node
>     validate_certs: "false"
>   connection: local
>   register: bigip_fact_out
>   #delegate_to: localhost
> 
> - debug: var=bigip_fact_out
> 
> 
> - name: Debug Msg Node
>   debug:
>       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
>   shell: |
>     #> /tmp/test
>     echo "{{ item.address }}"  | sed  -e "s/\/Common\///g" >> /tmp/test
>   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:
    dest: /tmp/test
    content: |
      {% for key, value in bigip_fact_out.ansible_facts.node | dictsort %}
      {{ value.address }}
      {% endfor %}

-- 
Kai Stian Olstad

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/7423443.j7AFbVePqF%40x1.
For more options, visit https://groups.google.com/d/optout.

Reply via email to