简体   繁体   English

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

[英]Ansible playbooks failing on ALL Ubuntu servers

I'm running Ansible on a CentOS server and can run playbooks successfully on Windows and RHEL/CentOS Linux servers but it struck me that I CANNOT get a playbook to run on ANY Ubuntu servers (v14.04, v16.04 or v18.04 - including AWS-hosted instances)!我在 CentOS 服务器上运行 Ansible,并且可以在 Windows 和 RHEL/CentOS Linux 服务器上成功运行剧本,但令我震惊的是我无法在任何 Ubuntu 服务器(v14.04、v18.04、v16.04 或 v16.04)上运行剧本- 包括 AWS 托管的实例)!

What is weird is that Anible hostname -m ping command works fine on all Ubuntu hosts however...奇怪的是Anible hostname -m ping 命令在所有 Ubuntu 主机上都能正常工作,但是......

I have tried updating CentOS and OpenSSH to the latest versions but to no avail.我已尝试将 CentOS 和 OpenSSH 更新到最新版本,但无济于事。 I am at my wits end trying to resolve this issue so I'm hoping someone can help me out...我无能为力地试图解决这个问题,所以我希望有人能帮助我......

My Ansible setup is as follows:我的 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 version: CentOS版本:

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

OpenSSH version: OpenSSH 版本:

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

Running the playbook in verbose mode yields the following output:在详细模式下运行剧本会产生以下 output:

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} “msg”:“ state 的值必须是以下之一:absent, build-dep, fixed, latest, present, got: installed ”, “failed”: true, “invocation”: {“module_args”: {“state”: “已安装”,“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}

A: The answer is included in the error message.答:答案包含在错误消息中。 See apt for details.有关详细信息,请参阅apt

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM