Kai - Thank you, I missed the space! This now works as I would have hoped.
Jon - Thank you too! Using a include_vars rather than a lookup achieves the
same goal, the single-line format of each item was something I completely
forgot you could do, for some reason I've adopted the multi-line format
and never let go.
Kind regards,
Asil
On Tuesday, October 4, 2016 at 10:12:40 AM UTC+1, Kai Stian Olstad wrote:
>
> On 04.10.2016 09:54, Asil Carlin wrote:
> > Hi Kai,
> >
> > Thanks for taking the time to reply. I did first try using with_lines
> > and
> > the awk command and using "item +", that throws up another error: This
> > code
> >
> > ---
> >
> > - hosts: localhost
> > become: True
> > become_user: root
> >
> > tasks:
> >
> > - name: get groups
> > command: /usr/bin/awk -F',' '!/^#/ && !/^$/ { print $1 }' /var/tmp/
> > groups.csv
> > register: groups_out
> >
> > - debug: var=groups_out.stdout_lines
> >
> > - name: Process groups one
> > group: >
> > name={{ lookup('csvfile', item + 'file=groups.csv col=0
> > delimiter=,') }}
> > gid={{ lookup('csvfile', item + 'file=groups.csv col=1
> > delimiter=,') }}
> > state={{ lookup('csvfile', item + 'file=groups.csv col=2
> > delimiter=,') }}
> > system={{ lookup('csvfile', item + 'file=groups.csv col=3
> > delimiter=,') }}
>
> If you look carefully at my example I have a space in front of file.
> Without it your name would be like this on first iteration
>
> lookup('csvfile', 'accountfile=groups.csv col=0 delimiter=,')
>
> And this is not a valid lookup.
>
> --
> Kai Stian Olstad
>
--
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/2852ba48-bff4-421f-9582-7c94178bcbf5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.