Ansible 剧本在所有 Ubuntu 个服务器上失败

Ansible playbooks failing on ALL Ubuntu servers

我在 CentOS 服务器上 运行ning Ansible 并且可以在 Windows 和 RHEL/CentOS Linux 服务器上成功 运行 剧本,但它让我震惊我无法在任何 Ubuntu 服务器(v14.04、v16.04 或 v18.04 - 包括 AWS 托管实例)上获得 运行 剧本!

奇怪的是 Anible hostname -m ping 命令在所有 Ubuntu 主机上工作正常 但是...

我已尝试将 CentOS 和 OpenSSH 更新到最新版本,但无济于事。我无能为力地试图解决这个问题,所以我希望有人能帮助我...

我的 Ansible 设置如下:

[root@ansible ansible]# ansible --version
ansible 2.9.3
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/site-packages/ansible
  executable location = /usr/bin/ansible
  python version = 2.7.5 (default, Aug  7 2019, 00:51:29) [GCC 4.8.5 20150623 (Red Hat 4.8.5-39)]

CentOS 版本:

[root@ansible ansible]# rpm -q centos-release
centos-release-7-7.1908.0.el7.centos.x86_64

OpenSSH 版本:

OpenSSH_7.4p1, OpenSSL 1.0.2k-fips  26 Jan 2017

运行 详细模式下的剧本产生以下输出:

TASK [Installing package nginx] ***************************************************************************************************************************************
task path: /etc/ansible/sample.yml:7
<192.168.xxx.xxx> ESTABLISH SSH CONNECTION FOR USER: root
<192.168.xxx.xxx> SSH: EXEC sshpass -d8 ssh -C -o ControlMaster=auto -o ControlPersist=60s -o 'User="root"' -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/e8342f25c3 192.168.xxx.xxx '/bin/sh -c '"'"'echo ~root && sleep 0'"'"''
<192.168.xxx.xxx> (0, '/root\n', '')
<192.168.xxx.xxx> ESTABLISH SSH CONNECTION FOR USER: root
<192.168.xxx.xxx> SSH: EXEC sshpass -d8 ssh -C -o ControlMaster=auto -o ControlPersist=60s -o 'User="root"' -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/e8342f25c3 192.168.xxx.xxx '/bin/sh -c '"'"'( umask 77 && mkdir -p "` echo /root/.ansible/tmp/ansible-tmp-1581462806.41-181529489855642 `" && echo ansible-tmp-1581462806.41-181529489855642="` echo /root/.ansible/tmp/ansible-tmp-1581462806.41-181529489855642 `" ) && sleep 0'"'"''
<192.168.xxx.xxx> (0, 'ansible-tmp-1581462806.41-181529489855642=/root/.ansible/tmp/ansible-tmp-1581462806.41-181529489855642\n', '')
Using module file /usr/lib/python2.7/site-packages/ansible/modules/packaging/os/apt.py
<192.168.xxx.xxx> PUT /root/.ansible/tmp/ansible-local-9871PVuptY/tmpt4YxAm TO /root/.ansible/tmp/ansible-tmp-1581462806.41-181529489855642/AnsiballZ_apt.py
<192.168.xxx.xxx> SSH: EXEC sshpass -d8 sftp -o BatchMode=no -b - -C -o ControlMaster=auto -o ControlPersist=60s -o 'User="root"' -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/e8342f25c3 '[192.168.xxx.xxx]'
<192.168.xxx.xxx> (0, 'sftp> put /root/.ansible/tmp/ansible-local-9871PVuptY/tmpt4YxAm /root/.ansible/tmp/ansible-tmp-1581462806.41-181529489855642/AnsiballZ_apt.py\n', '')
<192.168.xxx.xxx> ESTABLISH SSH CONNECTION FOR USER: root
<192.168.xxx.xxx> SSH: EXEC sshpass -d8 ssh -C -o ControlMaster=auto -o ControlPersist=60s -o 'User="root"' -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/e8342f25c3 192.168.xxx.xxx '/bin/sh -c '"'"'chmod u+x /root/.ansible/tmp/ansible-tmp-1581462806.41-181529489855642/ /root/.ansible/tmp/ansible-tmp-1581462806.41-181529489855642/AnsiballZ_apt.py && sleep 0'"'"''
<192.168.xxx.xxx> (0, '', '')
<192.168.xxx.xxx> ESTABLISH SSH CONNECTION FOR USER: root
<192.168.xxx.xxx> SSH: EXEC sshpass -d8 ssh -C -o ControlMaster=auto -o ControlPersist=60s -o 'User="root"' -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/e8342f25c3 -tt 192.168.xxx.xxx '/bin/sh -c '"'"'/usr/bin/python3 /root/.ansible/tmp/ansible-tmp-1581462806.41-181529489855642/AnsiballZ_apt.py && sleep 0'"'"''
<192.168.xxx.xxx> (1, '\r\n{"msg": "value of state must be one of: absent, build-dep, fixed, latest, present, got: installed", "failed": true, "invocation": {"module_args": {"state": "installed", "update_cache": true, "pkg": "nginx", "package": ["nginx"], "cache_valid_time": 0, "purge": false, "force": false, "dpkg_options": "force-confdef,force-confold", "autoremove": false, "autoclean": false, "only_upgrade": false, "force_apt_get": false, "allow_unauthenticated": false}}}\r\n', 'Shared connection to 192.168.xxx.xxx closed.\r\n')
<192.168.xxx.xxx> Failed to connect to the host via ssh: Shared connection to 192.168.xxx.xxx closed.
<192.168.xxx.xxx> ESTABLISH SSH CONNECTION FOR USER: root
<192.168.xxx.xxx> SSH: EXEC sshpass -d8 ssh -C -o ControlMaster=auto -o ControlPersist=60s -o 'User="root"' -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/e8342f25c3 192.168.xxx.xxx '/bin/sh -c '"'"'rm -f -r /root/.ansible/tmp/ansible-tmp-1581462806.41-181529489855642/ > /dev/null 2>&1 && sleep 0'"'"''
<192.168.xxx.xxx> (0, '', '')
fatal: [ubuntu_host]: FAILED! => {

"msg": "value of state must be one of: absent, build-dep, fixed, latest, present, got: installed", "failed": true, "invocation": {"module_args": {"state": "installed", "update_cache": true, "pkg": "nginx", "package": ["nginx"], "cache_valid_time": 0, "purge": false, "force": false, "dpkg_options": "force-confdef,force-confold", "autoremove": false, "autoclean": false, "only_upgrade": false, "force_apt_get": false, "allow_unauthenticated": false}

答:答案包含在错误信息中。有关详细信息,请参阅 apt