Hi Everyone,
I have created a playbook which reads a csv file and converts it into
variables then executes the task. My playbook is actually fine -- and
gives me what I expect to see, but I want to make my csv file format into
simpler –something like this:
"command","savefile"
"command","savefile"
"command","savefile"
"command","savefile"
My current csv file is like this:
-------------------
"ls -l /etc","ls_l"
"hostid","hostid_out"
"cat /etc/hosts","cat_hosts"
-------------------
Is there any better way to make my csv file simpler? Any thoughts?
My playbook is:
vars:
inputfile1: "./sample.csv"
tasks:
- debug: msg="Col1 = {{ col1 }} , Col2 = {{ col2 }}"
vars:
col1: "{{ lookup('csvfile', '{{ item }} file={{ inputfile1 }}
delimiter=, col=1') }}"
col2: "{{ lookup('csvfile', '{{ item }} file={{ inputfile1 }}
delimiter=, col=2') }}"
with_lines:
- awk -F, '{ print $1 }' "{{ inputfile1 }}"
< sample1.csv >
-------------------
1,"ls -l /etc","ls_l"
2,"hostid","hostid_out"
3,"cat /etc/hosts","cat_hosts"
-------------------
--
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/CAOpn5sRvKh%2Bs%2BR2f4CuRndHckOgyYJCQYLS9QTrRuNdunQ0p_Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.