Hello,
I'm attempting to create config files from one or more csv files. I want
the name of each config file to be the hostname (first field) within each
record read from the csv files. I think I'm close, but I can't seem to find
the right reference for that hostname value.
# This task is just for debugging
- name: Read the csv files
debug:
msg= "{{ item.split(',')[0] }}"
with_lines: "egrep -v '^name'
/home/sysadmin/TimsTest1/roles/opengear/files/*.csv"
Sample output:
TASK [opengear : Read the csv files]
***************************************************************************************************************************************
ok: [localhost] =>
(item=/home/sysadmin/TimsTest1/roles/opengear/files/USCAL3-File1.csv:USCAL3-IM7208-01,The
Lab
,America/New_York,10.103.50.6,10.9.167.218,10.10.61.71,10.103.50.1,255.255.255.224,[email protected],MyAddressHere
Flr-3,USCAL3-RW4451-01-03,USCAL3-RW4451-02-03,USCAL3-AS3650-01-03,USCAL3-AS3650-02-03,Port
5,RTR-A,RTR-B,Port 8) => {
"item":
"/home/sysadmin/TimsTest1/roles/opengear/files/USCFC3-File1.csv:USCFC3-IM7208-01,The
Lab
,America/New_York,10.103.50.6,10.9.167.218,10.10.61.71,10.103.50.1,255.255.255.224,[email protected],MyAddressHere
Flr-3,USCAL3-RW4451-01-03,USCAL3-RW4451-02-03,USCAL3-AS3650-01-03,USCAL3-AS3650-02-03,Port
5,RTR-A,RTR-B,Port 8",
"msg": ""
}
# Grab the files from the csv files and combine with the template
- name: Create OpenGear device configs
template:
src: "opengear8port.j2"
dest: "{{ item.split(',')[0] }}.xml"
with_lines: "egrep -v '^name'
/home/sysadmin/TimsTest1/roles/opengear/files/*.csv"
I want to see the file show up as": USCAL3-IM7208-01.xml
I hope that makes sense.
Thank you,
-Tim
--
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/08ee0f94-4659-4ecb-a18b-431de13c89b1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.