$ ansible all -m ansible.builtin.shell -a 'echo $TERM'
ERROR! this task 'ansible.builtin.shell' has extra params, which is only
allowed in the following modules: import_role, win_command,
include_vars, include_tasks, raw, win_shell, command, add_host,
meta, include_role, shell, import_tasks, group_by, set_fact, script, include
谁能帮我找出问题所在
这是带有-vvv
标签的
$ ansible -vvv centos -m ansible.builtin.shell -a 'echo $TERM'
ansible 2.9.6
config file = /etc/ansible/ansible.cfg
configured module search path = ['/home/chandru/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3/dist-packages/ansible
executable location = /usr/bin/ansible
python version = 3.8.5 (default, Jul 28 2020, 12:59:40) [GCC 9.3.0]
Using /etc/ansible/ansible.cfg as config file
host_list declined parsing /etc/ansible/hosts as it did not pass its verify_file() method
script declined parsing /etc/ansible/hosts as it did not pass its verify_file() method
auto declined parsing /etc/ansible/hosts as it did not pass its verify_file() method
Parsed /etc/ansible/hosts inventory source with ini plugin
ERROR! this task 'ansible.builtin.shell' has extra params, which is only allowed in the following modules: group_by, include_tasks, set_fact, raw, add_host, win_shell, win_command, include_vars, meta, import_role, command, script, include, shell, import_tasks, include_role
答案1
这是由于 Ansible 中的一个错误造成的,该错误是作为向 FQCN 过渡的一部分引入的:https://github.com/ansible/ansible/pull/71824
作为解决方法,您可以简单地替换ansible.builtin.shell
为旧学校shell
名称。
答案2
你可以尝试一下:
$ ansible all -m shell -a 'echo $TERM'
我的环境:
root@ubuntu:~/ansiblelearn# ansible --version
ansible 2.9.6
config file = /etc/ansible/ansible.cfg
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3/dist-packages/ansible
executable location = /usr/bin/ansible
python version = 3.8.10 (default, Nov 26 2021, 20:14:08) [GCC 9.3.0]