Код: Выделить всё
---
- name: Gather local user information and create a report
hosts: all # Target all hosts in your inventory
gather_facts: no
tasks:
- name: Get user information
ansible.builtin.shell: |
getent passwd | awk -F: '{print $1","$3","$4","$6","$7}'
register: user_data
- name: Construct per-host user report
ansible.builtin.set_fact:
host_user_report: |
### Users on {{ ansible_hostname }} ({{ inventory_hostname }}) ###
Username,UID,GID,Home Directory,Shell
{{ user_data.stdout }}
- name: Append per-host report to a single file on the control node
ansible.builtin.copy:
content: "{{ host_user_report }}\n\n"
dest: "/tmp/ansible_user_report.txt"
mode: '0644'
delegate_to: localhost
run_once: true
Подробнее здесь: https://stackoverflow.com/questions/797 ... t-document
Мобильная версия