【发布时间】:2021-06-02 10:54:57
【问题描述】:
我正在尝试获取我在主机上创建的所有用户。当我在终端上运行以下命令时,我得到了机器上的所有用户。
sudo getent passwd {1000..6000} | cut -d":" -f1
但是,当我尝试使用 ansible 运行它时,出现错误。我试过用双引号括起来,转义括号,将输出管道传输到 cat 等,但没有任何效果。
---
- name: "run commands"
become: true
gather_facts: no
hosts: all
tasks:
- name: list all users
shell: getent passwd {1000..6000} | cut -d":" -f1
register: getent
- debug: var=getent.stdout_lines
【问题讨论】:
-
错误信息是什么?
标签: bash automation ansible