On Wed, 24 Aug 2022 02:17:38 -0700 (PDT)
Kenady Inampudi <[email protected]> wrote:

>     - shell: id "{{ item }}"
>       register: id
>       with_items: "{{ userid.stdout.split('\n') }}"
>     - debug:
>         var: id.stdout_lines

The variable *id* was registered in a loop. You need the attribute
*results*. (Take a look at *id*.)

Try

    - debug:
        msg: "{{ id.results|map(attribute='stdout')|list }}"


Notes:

* Use *getent* instead of reading /etc/passwd* on your own
https://docs.ansible.com/ansible/latest/collections/ansible/builtin/getent_module.html

* Use *command* instead of *shell*, *loop* instead of *with_items*,
  and *userid.stdout_lines* instead of *userid.stdout.split('\n')*

    - command: "id {{ item }}"
      register: id
      loop: "{{ userid.stdout_lines }}"

-- 
Vladimir Botka

-- 
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/20220824123753.15430d86%40gmail.com.

Attachment: pgpxYhl8iAPV7.pgp
Description: OpenPGP digital signature

Reply via email to