我建立了一个新的Ansible项目,我想在其中连接到我的EC2机器并运行一些命令。
我添加了清单文件,当我测试一个简单的Ansible命令时,一切都很好,我得到了响应。
ansible all -m shell -a 'uptime'
或
ansible all -m ping
工作良好,并返回预期输出。
然而,当我试图运行一个使用内置shell模块的简单剧本时,它失败了。
可靠的剧本命令:
ansible-playbook -vvv playbooks/my_playbook.yaml
行动手册文件:
---
- hosts: all
become: yes
gather_facts: yes
tasks:
- name: Gather EC2 facts
action: ec2_facts
- hosts: all
become: yes
tasks:
- name: my task
shell: uptime
收集EC2事实运行良好,但运行shell命令的第二部分失败,出现以下异常:
<1.2.3.4> Failed to connect to the host via ssh:
fatal: [1.2.3.4]: FAILED! => {
"changed": false
}
MSG:
This module has been removed. The module documentation for Ansible-2.6 may contain hints for porting
我不明白为什么会出现这个异常,因为shell模块从未被弃用过。
我也不使用Ansible-2.6,我通过pip安装了Ansible,版本:
ansible==2.9.27
ansible-core==2.15.8
我试图更改为命令模块,这导致了同样的异常,所以我怀疑它必须对我的本地环境而不是shell模块本身进行处理。
如有任何帮助,我们将不胜感激。