gpt4 book ai didi

Ansible 无法运行任何命令或 shell

转载 作者:行者123 更新时间:2023-12-05 01:31:22 25 4
gpt4 key购买 nike

我在我的 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 说它是最新的。

如有任何帮助,我们将不胜感激。

最佳答案

ansible.builtin.command 替换为 command。您的 Ansible 版本对于较新的语法来说太旧了。这适用于 Ansible 2.9.6:

- hosts: localhost
gather_facts: false
tasks:
- command: cat /etc/motd

关于Ansible 无法运行任何命令或 shell,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66431114/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com