I've written a seemingly simple ansible task to connect to an ec2 instance and configure the timezone. The ansible task is as follows
---
- name: Set Time Zone variables
copy: content='Etc/UTC' dest=/etc/timezone owner=root group=root mode=0644 backup=yes
and the command used to run the task is
ansible-playbook nectar.yml --extra-vars "ansible_python_interpreter=/usr/local/bin/python env=DEVELOPMENT" -vvvv
my ansible.cfg looks like
[defaults]
inventory = hosts
[ssh_connection]
ssh_args = -o ControlMaster=auto -o ControlPersist=60s
But I keep getting the error message
<54.237.211.85> ESTABLISH SSH CONNECTION FOR USER: ubuntu
<54.237.211.85> SSH: EXEC ssh -vvv -o ControlMaster=auto -o ControlPersist=60s -o Port=22 -o 'IdentityFile="./nectar-web.pem"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=ubuntu -o ConnectTimeout=10 -o StrictHostKeyChecking=no -o ControlPath=/Users/reagan/.ansible/cp/5113bdcc33 -tt 54.237.211.85 '/bin/sh -c '"'"'/usr/local/bin/python /home/ubuntu/.ansible/tmp/ansible-tmp-1522003225.61-27057727697133/command.py; rm -rf "/home/ubuntu/.ansible/tmp/ansible-tmp-1522003225.61-27057727697133/" > /dev/null 2>&1 && sleep 0'"'"''
<54.237.211.85> (0, '/bin/sh: 1: /usr/local/bin/python: not found\r\n', 'OpenSSH_7.4p1, LibreSSL 2.5.0\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: auto-mux: Trying existing master\r\ndebug2: fd 3 setting O_NONBLOCK\r\ndebug2: mux_client_hello_exchange: master version 4\r\ndebug3: mux_client_forwards: request forwardings: 0 local, 0 remote\r\ndebug3: mux_client_request_session: entering\r\ndebug3: mux_client_request_alive: entering\r\ndebug3: mux_client_request_alive: done pid = 98004\r\ndebug3: mux_client_request_session: session request sent\r\ndebug1: mux_client_request_session: master session id: 2\r\ndebug3: mux_client_read_packet: read header failed: Broken pipe\r\ndebug2: Received exit status from master 0\r\nShared connection to 54.237.211.85 closed.\r\n')
fatal: [54.237.211.85]: FAILED! => {
"changed": false,
"module_stderr": "OpenSSH_7.4p1, LibreSSL 2.5.0\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: auto-mux: Trying existing master\r\ndebug2: fd 3 setting O_NONBLOCK\r\ndebug2: mux_client_hello_exchange: master version 4\r\ndebug3: mux_client_forwards: request forwardings: 0 local, 0 remote\r\ndebug3: mux_client_request_session: entering\r\ndebug3: mux_client_request_alive: entering\r\ndebug3: mux_client_request_alive: done pid = 98004\r\ndebug3: mux_client_request_session: session request sent\r\ndebug1: mux_client_request_session: master session id: 2\r\ndebug3: mux_client_read_packet: read header failed: Broken pipe\r\ndebug2: Received exit status from master 0\r\nShared connection to 54.237.211.85 closed.\r\n",
"module_stdout": "/bin/sh: 1: /usr/local/bin/python: not found\r\n",
"msg": "MODULE FAILURE",
"rc":
Any ideas on why ansible keeps getting this error when reusing the master connection?
答案 0 :(得分:0)
如果我要在香草ubuntu AMI上运行某些东西,那就在playbook上做了类似的事情。
---
- hosts: all
remote_user: someuser
gather_facts: False
pre_tasks:
- name: Install python for Ansible
raw: test -f /usr/bin/python || (apt -y update && apt install -y python-minimal)
become: true
```
- setup: # aka gather_facts
答案 1 :(得分:-2)
尝试在目标机器python上安装。 我有同样的错误:
dworker-01 | FAILED! => {
"changed": false,
"module_stderr": "Shared connection to dworker-01 closed.\r\n",
"module_stdout": "/bin/sh: 1: /usr/local/bin/python: not found\r\n",
"msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
"rc": 127
}
目标机器:
apt-get update && apt-get install python
之后,一切都好。