【发布时间】:2020-12-30 14:02:44
【问题描述】:
---
- 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
没有给出预期的输出,因为我在 shell 模块中使用 awk / grep 时遇到语法错误。请参考预期的输出。
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
..
【问题讨论】:
标签: shell module ansible ansible-template