I need to loop over multiple files (sudoers, /etc/sudoers.d/*), and for
each file I need to register the output and then write it to a file. How
would I nest the following code (if possible)?
- name: Gather sudo users
shell: "/bin/cat /etc/{{item}} | grep -ve ^$ -e ^# -e ^Defaults"
register: sudo_users
with_items:
- sudoers
- sudoers.d/*
- name: Write sudo users
lineinfile:
dest: "/tmp/{{ansible_nodename}}.sudoers"
line: "test"
insertafter: EOF
create: yes
state: present
delegate_to: localhost
As you can see from the above I just write to sudo_users var to the file,
but it is only for the very last instance. I would like to capture it for
each file.
--
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/8c7120e7-ed88-4e77-aff6-f354094bd574%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.