---
- name: Data Collection
hosts: all
tasks:
- name: List all users
shell: "cat /etc/passwd | awk -F: '{print $1}'"
register: users
- lineinfile:
dest: /tmp/users.csv
create: yes
line: "The {{ inventory_hostname}}, {{ users.stdout }}"
delegate_to: localhost
Doesn't give the intended output as I'm getting syntax error for using awk / grep in shell module. Kindly refer the intended output.
172.17.254.201, root
172.17.254.201, bin
172.17.254.201, nobody
172.17.254.201, test1
172.17.254.201, test2
172.17.254.202, root
172.17.254.202, bin
172.17.254.202, nobody
172.17.254.202, test1
172.17.254.202, test2
..
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…