If I leave the playbook like this:
- name: check if existing user is in sudoers
command: grep {{ item }} /etc/sudoers
with_items: "{{ out.results }}"
register: message
it attempts to run a grep on all output from out.results.
On Wednesday, May 20, 2020 at 3:21:31 PM UTC-4, Jerry Jerry wrote:
>
> Trying to check if a user exists locally and if true, check to see if it
> has sudo rights. I can't seem to process the second loop. I tried using
> out.results.item but error:
>
> fatal: [hostname]: FAILED! => {"msg": "'list object' has no attribute
> 'item'"}
>
> ---
> - hosts: all
> gather_facts: no
> become: yes
> tasks:
> - name: check user exists
> command: grep {{ item }} /etc/passwd
> failed_when: False
> register: out
> with_items:
> - user1
> - user2
> - user3
>
> - debug:
> var: out
>
> - name: check if existing user is in sudoers
> command: grep {{ item }} /etc/sudoers
> with_items: "{{ out.results }}"
> register: message
>
> - debug:
> var: message
>
--
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 view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/a538abc4-6474-4a79-ba79-55a37c2ad107%40googlegroups.com.