save stdout to file on localhost.

i want to query all the users on the hosts of my inventory and create afile for each hosts with all the privileges for each user

I know that htere tools like freeipa but we do not have those in place

so i am using the getent wrapper to get all the users on the hosts included the netgroups… run sudo -lU on each of these hosts and save the output to file by using stdout or stdout_lines.

the problems is only one username is saved to the file and not all of them

this is the playbook:

`

This should work:

  - name: save to file
    copy:
      content: "{{ sudo_rights.results | map(attribute='stdout') | join('\n') }}"
      dest: privs_{{inventory_hostnam}}
    delegate_to: localhost

You can't use run once, since you need the task to run one time for each host.