gpt4 book ai didi

ansible - 为什么我无法 Ansible ping 我的测试仪?

转载 作者:行者123 更新时间:2023-12-02 13:11:43 26 4
gpt4 key购买 nike

我正在尝试运行 Ansible Up and Running 书中的示例。

我的剧本目录

ls
ansible.cfg hosts ubuntu-bionic-18.04-cloudimg-console.log Vagrantfile

主机

testserver ansible_host=127.0.0.1 ansible_port=2222

ansible.cfg

[defaults]
inventory = hosts
remote_user = vagrant
private_key_file = .vagrant/machines/default/virtualbox/private_key
host_key_checking = False

流浪文件

   config.vm.box = "ubuntu/bionic64"

当我尝试 ping 时

ansible testserver -m ping

我得到

testserver | FAILED! => {
"changed": false,
"module_stderr": "Shared connection to 127.0.0.1 closed.\r\n",
"module_stdout": "/bin/sh: 1: /usr/bin/python: not found\r\n",
"msg": "MODULE FAILURE",
"rc": 127
}

我可以毫无问题地进行 ssh

ssh vagrant@127.0.0.1 -p 2222 -i /home/miki/playbooks/.vagrant/machines/default/virtualbox/private_key
Welcome to Ubuntu 18.04.2 LTS (GNU/Linux 4.15.0-50-generic x86_64)


System information as of Tue May 21 06:39:46 UTC 2019

System load: 0.0 Processes: 108
Usage of /: 18.5% of 9.63GB Users logged in: 0
Memory usage: 17% IP address for enp0s3: 10.0.2.15
Swap usage: 0%





Last login: Tue May 21 06:32:13 2019 from 10.0.2.2

为什么 ansible ping 不起作用?

最佳答案

来自错误消息

"module_stdout": "/bin/sh: 1: /usr/bin/python: not found\r\n", 

远程主机似乎没有安装python。

引自requiremet docs

On the managed nodes, you need a way to communicate, which is normally ssh. By default this uses sftp. If that’s not available, you can switch to scp in ansible.cfg. You also need Python 2 (version 2.6 or later) or Python 3 (version 3.5 or later).

Ansible 需要远程主机中存在 python。

另外,关于ping模块的使用,it's not the same as ping shell command.

尝试在远程主机中安装 python(手动或使用 raw 模块),然后重新运行脚本。

关于ansible - 为什么我无法 Ansible ping 我的测试仪?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56232484/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com