本文介绍了Ansible + 10.11.6的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 10.11.6 的(非常)干净的安装中遇到了 Ansible 的奇怪问题.我已经安装了 brew、zsh、oh-my-zsh、Lil' snitch 和 1password(实际上没有别的).我安装了 ansible ......

I'm having a weird issue with Ansible on a (very) clean install of 10.11.6. I've installed brew, zsh, oh-my-zsh, Lil' snitch and 1password (and literally nothing else). I installed ansible with...

brew install ansible

... 成功了.然后我去了一个预先存在的(而且非常简单)Ansible 项目并做了一个......

... which was successful. I then went to a preexisting (and crazy simple) Ansible project and did an...

ansible -m ping all

然后它要求我输入我的 SSH 密码.我已经恢复了之前安装的密钥,但我之前没有 ssh 进入服务器.我输入了密码,ansible 返回了...

It then asked me to enter my SSH passphrase. I've reinstated the keys from my previous install but I hadn't previously ssh'd into the server. I entered the passphrase and ansible returned...

$ ansible -m ping all               
host1 | UNREACHABLE! => {
"changed": false, 
"msg": "Failed to connect to the host via ssh.", 
"unreachable": true
}

然后我通过 ssh 进入服务器检查一切正常,并且连接没有任何问题.

I then ssh'd into the server to check all was well, and it connected without any problems.

然后我重新运行...

$ ansible -m ping all

它返回了...

host1 | FAILED! => {
"changed": false, 
"failed": true, 
"module_stderr": "", 
"module_stdout": "/bin/sh: 1: /usr/bin/python: not found\r\n", 
"msg": "MODULE FAILURE", 
"parsed": false
}

...这有点奇怪?似乎是说它再也找不到 python了,尽管它是第一次找到它?

... which is a bit weird? It seems to be saying it can't find python anymore, despite it finding it first time around?

$ which python 返回 /usr/bin/python

$ python --version 返回 Python 2.7.10

$ which ansible 返回 /usr/local/bin/ansible

$ ansible --version 返回

ansible 2.1.1.0
config file = /pathtoproject/ansible.cfg
configured module search path = Default w/o overrides

我故意没有安装pyenv、virtualenv等

I've deliberately not installed pyenv, virtualenv etc.

/usr/bin/python 肯定存在,我可以毫无问题地运行 python.

/usr/bin/python is definitely there, and I can run python without any problems.

帮助?!:-) 我是一个 Ruby 开发者,我不禁觉得我遗漏了一些明显的东西,但据我所知,所有版本都检查出来了,一切应该正常工作.我尝试将我的 shell 更改为 sh 并重新运行 ansible -m ping all 但它以同样的方式失败.

Help?! :-) I'm a Ruby dev and I can't help but think I'm missing something obvious, but as I understand it all the versions check out and everything should be working. I tried changing my shell to sh and rerunning ansible -m ping all but it fails in the same way.

有什么想法吗?

推荐答案

如果远程主机上没有安装 python,就会发生这种情况.ansible 文档 建议手动为每个主机执行此操作:ansible myhost --sudo -m raw -a "yum install -y python2 python-simplejson"

This happens if there is no python installed on the remote hosts.The ansible documentation suggests doing this for every host by hand: ansible myhost --sudo -m raw -a "yum install -y python2 python-simplejson"

但是,我认为在您的剧本开头使用此代码段引导所有主机会更好:

However I think it's nicer to bootstrap all of your hosts with this snippet at the start of you playbook:

- 名称:Bootrstrap python主机:本地主机任务:原始:sudo apt-get 更新 &&须藤 apt-get -y python-simplejsondelegate_to: '{{ item }}'with_items: {{ 组["hosts"] }}

这篇关于Ansible + 10.11.6的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 16:19