【发布时间】:2020-08-08 14:45:47
【问题描述】:
我正在尝试使用“lineinfile”通过临时命令作为 ROOT 通过 Ansible 服务器向 Ansible 节点添加权限:
ansible -i rec-apache.inv -m lineinfile -a "path=/etc/sudoers \
line ='ansible-node1 ALL=(ALL:ALL) NO PASSWD:ALL'" --become-method=su --become -K all
我收到以下错误
ERROR! this task 'lineinfile' has extra params, which is only allowed in the following modules:
shell, win_shell, include_vars, add_host, raw, include_role, meta, set_fact, include,
import_tasks, script, import_role, include_tasks, group_by, command, win_command
我已经完成了密钥交换,一切顺利。仅当我在服务器端使用 root 用户时才会出现此问题。 我知道我可以使用 playbook 来做到这一点,但我对 ad-hoc 命令很感兴趣。谢谢!
【问题讨论】:
-
尝试在
line后面不加空格,例如:line='ansible-node1 ALL=(ALL:ALL) NO PASSWD:ALL'?
标签: linux ansible privileges sudoers ansible-ad-hoc