[英]Ansible AWS dynamic inventory connection not working
I am trying to configure a server on AWS using ansible with a dynamic inventory script. 我正在尝试使用带有动态清单脚本的ansible在AWS上配置服务器。
I created an ec2 instance which works fine and which I can manually ssh into. 我创建了一个ec2实例,该实例运行良好,可以手动ssh进入。 However, when trying to reach the instance (just to ping or to install software) I run into trouble. 但是,当尝试访问该实例(仅用于ping或安装软件)时,我遇到了麻烦。
ansible -i ec2.py all -m ping
xx.xx.xx.xx | FAILED! => {
"changed": false,
"failed": true,
"module_stderr": "Shared connection to xx.xx.xx.xx closed.\r\n",
"module_stdout": "/bin/sh: 1: /usr/bin/python: not found\r\n",
"msg": "MODULE FAILURE",
"rc": 0
} }
and for 和为
ansible-playbook deploy_site.yml -i ec2.py all
ERROR! the playbook: all could not be found
my all file lives in the directory group_vars 我的所有文件都位于目录group_vars中
playbook
- deploy_site.yml
/group_vars
-all
and looks like 看起来像
ansible_user: ubuntu
ansible_ssh_private_key_file: ~/.ssh/key_pair.pem
my key_pair.pem file exists and with mod=600 我的key_pair.pem文件存在且mod = 600
All of this happens in a virtual environment specific ansible and both host and server are ubuntu 16.04. 所有这一切都发生在特定的虚拟环境中,并且主机和服务器均为ubuntu 16.04。
Any thoughts on the reason for the connection problem? 对连接问题的原因有何想法?
Please share the output of ls /usr/bin/python*
and what is your ansible
version. 请分享输出ls /usr/bin/python*
,什么是你的ansible
版本。
Also try to install python and configure it on your group_vars
: 也尝试安装python并在group_vars
上配置它:
apt-get install -y python-dev python3 python3-dev python3-setuptools
in your file try to do something like this: 在您的文件中尝试执行以下操作:
ansible_user: ubuntu
ansible_ssh_private_key_file: ~/.ssh/key_pair.pem
ansible_python_interpreter=/usr/bin/python3
you can also try : 您也可以尝试:
ansible -i ec2.py all -m ping -e 'ansible_python_interpreter=/usr/bin/python3'
The first problem: 第一个问题:
/bin/sh: 1: /usr/bin/python: not found\\r\\n"
You must have Python installed on the target machine as well as on the control machine. 您必须在目标计算机以及控制计算机上都安装了Python。
The second problem: 第二个问题:
ansible-playbook deploy_site.yml -i ec2.py all
Remove all
from the command. 从命令中删除all
。
With ansible-playbook
you specify the target hosts inside the playbook with hosts
directive. 在ansible-playbook
您ansible-playbook
使用hosts
指令在ansible-playbook
指定目标主机。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.