Hello,
I'm fairly new to Ansible and trying to do something very simple.  I want 
to collect a piece of information (version number) from a number a network 
devices and generate a simple report.


 - name: Get Data from devices
   gather_facts: False
   hosts: all
   connection: local
   roles:
     - Juniper.junos

   tasks:

        - name: Netconf test
          wait_for: host={{ inventory_hostname }} port=830  timeout=5

        # Do a quick test to gather facts
        - name: Getting Facts
          junos_get_facts: host={{ inventory_hostname }} logfile=tmp.log 
user=me passwd=passwd123
          register: data

        - name: Save version data to jinja2 template
          template: src=junos_version_report.j2 dest=./ver_report.txt

Here is the j2 file:

Device         Serial Number         Version
---------      -------------         ------------
{% for i in play_hosts %}
{{ i }}     {{ data.facts.serialnumber }}
{% endfor %}


The problem is when the report is written to the file, the information in 
the "data" variable is only from the last device that set it... As you can 
see, the Serial number is reported as being identical for each device ( 
which it is not...)

Device     Serial Number         Version
---------      -------------         ------------
dev1     77633B97ACF0
dev2     77633B97ACF0
dev3     77633B97ACF0


I've seen an example like this with the hostvars variable but how do I 
define my own variable to be an array like hostvars so I can then reference 
each object in the array.  For example:

{{ data[i].facts.serialnumber }}

Or open to other ideas?

Thanks
Al


-- 
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/8974cb72-27ee-4e4e-97c0-a1b800916584%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to