【问题标题】:Unable to connect to ubuntu 16.04 using ansible无法使用 ansible 连接到 ubuntu 16.04
【发布时间】:2016-10-13 07:12:44
【问题描述】:

我正在使用 ansible playbook 来创建新的 AWS EC2 实例。我正在从 host1 运行我的 playook,然后想在新创建的 EC2 实例(host2)上运行一些任务。如果我的 EC2 ubuntu 是 14.04,我可以运行所有的 ansible 任务,但是如果我更改为 ubuntu 16.04,它会在 ping 上失败。尝试从 host1 ansible host2 -m ping ping 时出现以下错误

 "module_stdout": "/bin/sh: 1: /usr/bin/python2.7: not found\r\n",

我看到几个地方提到 ubuntu 16.04 带有 python 3,而 ansible 不支持 3,因此我们需要安装 ansible 2.7。我的困惑是,当 ansible 一开始就无法连接时,如何在我的 EC2 实例上安装 python。

知道如何解决这个问题吗?

谢谢, 迪帕克

【问题讨论】:

标签: amazon-ec2 ansible ansible-playbook ubuntu-16.04


【解决方案1】:

您可以使用“原始”模块通过 Python 2.x 引导系统。

例如:

ansible host2 --sudo -m raw -a "apt-get install -y python2.7 python-simplejson"

文档:http://docs.ansible.com/ansible/intro_installation.html

http://serverascode.com/2016/08/16/ansible-python2-xenial.html

如果您的存储库没有 2.7,您可以从 deadsnakes 存储库安装它,只需添加此 ppa;

ppa:fkrull/deadsnakes-python2.7

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-03-16
    • 2016-08-20
    • 2018-01-07
    • 1970-01-01
    • 2018-04-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多