Ansible AWS 动态库存连接不起作用 [英] Ansible AWS dynamic inventory connection not working

查看:23
本文介绍了Ansible AWS 动态库存连接不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用带有动态清单脚本的 ansible 在 AWS 上配置服务器.

I am trying to configure a server on AWS using ansible with a dynamic inventory script.

我创建了一个 ec2 实例,它运行良好,我可以手动 ssh 进入.但是,在尝试访问实例时(只是为了 ping 或安装软件),我遇到了麻烦.

I created an ec2 instance which works fine and which I can manually ssh into. However, when trying to reach the instance (just to ping or to install software) I run into trouble.

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

}

为了

ansible-playbook deploy_site.yml -i ec2.py all

ERROR! the playbook: all could not be found

我的所有文件都在目录 group_vars 中

my all file lives in the directory group_vars

playbook
- deploy_site.yml
/group_vars
  -all

看起来像

ansible_user: ubuntu
ansible_ssh_private_key_file: ~/.ssh/key_pair.pem

我的 key_pair.pem 文件存在并且 mod=600

my key_pair.pem file exists and with mod=600

所有这些都发生在特定于 ansible 的虚拟环境中,并且主机和服务器都是 ubuntu 16.04.

All of this happens in a virtual environment specific ansible and both host and server are ubuntu 16.04.

对连接问题的原因有什么想法吗?

Any thoughts on the reason for the connection problem?

推荐答案

请分享 ls/usr/bin/python* 的输出以及你的 ansible 版本.

Please share the output of ls /usr/bin/python* and what is your ansible version.

还尝试安装 python 并在您的 group_vars 上进行配置:

Also try to install python and configure it on your 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

你也可以试试:

ansible -i ec2.py all -m ping -e 'ansible_python_interpreter=/usr/bin/python3'

这篇关于Ansible AWS 动态库存连接不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆