Re: [ansible-project] Can someone show a working example of how to iterate over the rows of a csv file?

2018-02-22 Thread Nico Sabbi
Sorry, but  it's not clear at all how debug iterates over the rows. 
Running a simple debug doesn't help.

For example, if I had a playbook like this (that of course doesn't work), 
how should I fix it
to iterate over every single row and print the value of the 3 columns?

---
  - hosts: db
become: true
remote_user: root
vars:
  csvfile: "{{ lookup('csvfile', 'file=file.csv delimiter=,') }}"
  
tasks:
  - name: cat
debug: msg="{{ item.a }} - {{ item.a }} - {{ item.c }}"  #for every 
row print the value of a, b and c columns
with_items: csvfile
  

Thanks.


Il giorno mercoledì 21 febbraio 2018 18:58:28 UTC, Brian Coca ha scritto:
>
> there are plenty of specific examples, just your specific case is not 
> covered, but it is simple enough to inffer from existing ones, 
> something like this should work: 
>
> - name: show the row 
>   debug: var=item 
>   loop: " {{ lookup('file', '/path/tocsv') }}" 
>
>
> you might need to split on ',' if you want the columns, there is a 
> csvfile lookup it it retrieves specific column, not rows 
>
>
> -- 
> -- 
> Brian Coca 
>

-- 
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/353fcee5-0cbc-476c-8a74-84627e14de3d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Can someone show a working example of how to iterate over the rows of a csv file?

2018-02-21 Thread Brian Coca
there are plenty of specific examples, just your specific case is not
covered, but it is simple enough to inffer from existing ones,
something like this should work:

- name: show the row
  debug: var=item
  loop: " {{ lookup('file', '/path/tocsv') }}"


you might need to split on ',' if you want the columns, there is a
csvfile lookup it it retrieves specific column, not rows


-- 
--
Brian Coca

-- 
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/CACVha7fE_RnOcdnrkJGRkpWzkYNpMVpnaW_Q2%3Dyr4p-P_mbheQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Can someone show a working example of how to iterate over the rows of a csv file?

2018-02-21 Thread Nico Sabbi
HI,
I find Ansible  docs *really* frustrating. Never a full example  that is 
not trivial or misleading.

Please, can someone provide a working example of a play to iterate over the 
rows of a csvfile?

Thanks.

-- 
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/f988c03c-d68d-490b-b8e5-7d47dcc1c509%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.