简体   繁体   English

Ansible AWS动态清单连接不起作用

[英]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-playbookansible-playbook使用hosts指令在ansible-playbook指定目标主机。

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

相关问题 Ansible AWS 动态清单实例过滤器不起作用 - Ansible AWS dynamic inventory instance filters not working 与AWS连接时的动态库存 - Ansible dynamic inventory when connecting with AWS 为 Ansible ec2 动态清单配置多个 AWS 账户 - Configuring multiple AWS Accounts for Ansible ec2 dynamic inventory 将 Ansible 与 AWS 动态清单 (ec2.py) 结合使用 - Using Ansible with AWS dynamic inventory (ec2.py) 设置Ansible服务器以使用动态清单管理多个AWS账户吗? - Setup Ansible server to manage several AWS Accounts using dynamic inventory? Google Cloud 上的 Ansible Controller 和 EC2 AWS 上的节点的动态清单 - Dynamic inventory for Ansible Controller on Google Cloud and nodes on EC2 AWS 带有动态子项的静态组的 Ansible 动态清单 - Ansible Dynamic inventory with static group with dynamic children AWS / Ansible-如何从动态清单中定义的主机跨角色/主机访问事实? - AWS/Ansible - How to access facts across roles/hosts from host defined in dynamic-inventory? 具有标签和动态清单的Ansible AWS ec2模块返回错误的主机 - Ansible AWS ec2 module with tags and dynamic inventory returns wrong hosts 动态清单文件上的 Ansible + AWS EC2 插件 + 用户名 + ssh 密钥 - Ansible + AWS EC2 Plugin + username + ssh key on the dynamic inventory file
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM