我无法在 RPi 上运行任何命令或 shell。
当我使用以下代码时:
- name: Example command
ansible.builtin.command:
cmd: "cat /etc/motd"
我收到此错误:
Unsupported parameters for (ansible.builtin.command) module: cmd Supported parameters include: _raw_params, _uses_shell, argv, chdir, creates, executable, removes, stdin, stdin_add_newline, strip_empty_ends, warn"}
当我尝试这个时:
- name: Example command
ansible.builtin.command: cat /etc/motd
我收到此错误:
ERROR! this task 'ansible.builtin.command' has extra params, which is only allowed in the following modules: import_tasks, raw, include, include_tasks, include_vars, include_role, script, set_fact, win_command, add_host, shell, import_role, group_by, command, win_shell, meta
当我尝试使用 ansible.builtin.shell 时,我遇到了同样的错误。我尝试了其他几个命令,但没有任何运气。如果没有这两个错误,我似乎无法运行任何命令。
我使用 ansible 2.9.6。我试图升级它,但 apt 说它是最新的。
任何帮助将不胜感激。
答案 0 :(得分:4)
将 ansible.builtin.command
替换为 command
。您的 Ansible 版本对于较新的语法来说太旧了。这适用于 Ansible 2.9.6:
- hosts: localhost
gather_facts: false
tasks:
- command: cat /etc/motd