Oh, and you can drop the csv_to_facgts.py in ./library in your project 
folder...your playbook should then be able to use the module.

---


  - name: import csv
    csv_to_facts:
      src: "{{ some_csv_file }}"   
      table: mainTable              # optionally name the table....helpful 
if your playbook later imports add'l csv's


   - name: "loop through 'Spine' rows and create directories and switch 
configs"
    include: core_loop_rows.yml
      destination={{ base_dir }}/{{ item1['zone'] }}
      zone={{ item1['zone'] }}
      building={{ item1['building'] }}
      location={{ item1['locationName']}}
      host_name={{ item1['hostName'] }}
      device_type={{ item1['deviceType'] }}
      core_link_1={{ item1['int1'] }}
      core_link_2={{ item1['int2'] }}
      farend_core_link_1={{ item1['int1'] }}
      farend_core_link_2={{ item1['int2'] }}
      default_iface_mask={{ item1['mask'] }}
      core_link_1_ip={{ item1['int1_ip'] }}
      core_link_2_ip={{ item1['int2_ip'] }}
      core_1_name='core1'
      core_2_name='core2'
      loop0_ip={{ item1['Loop0'] }}
    with_items: "{{ mainTable }}"     # Now we can loop through the rows of 
the csv and access cells by the column header name
                                      # e.g. my csv file has column headers 
"Loop0", "locationName", "zone", etc.
    loop_control:
      loop_var: item1



On Tuesday, February 27, 2018 at 12:38:50 PM UTC-6, bill paxton wrote:
>
> Take a look at csv_to_facts module 
> <https://github.com/joelwking/ansible-nxapi>
>
> I found this to be quick and dirty way to access data from a spreadsheet 
> -> converted to csv first.  Look inside the .py for extra info on how to 
> use it.
>
>
>

-- 
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/feb75f38-8187-4c6f-ba12-d2fdedc139df%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to