我现在在用stream浪汉
我可以从本地terminalping虚拟机。
我想用ping命令来监视那个stream浪的虚拟机:
$ ansible 192.168.33.101 -m ping -u root
但有错误:
192.168.33.101 | UNREACHABLE! => { "changed": false, "msg": "Failed to connect to the host via ssh: Permission denied (publickey,password).\r\n", "unreachable": true }
我在/etc/ansible/hosts文件中添加了IP:
192.168.33.101
本地和虚拟机都安装了ssh。 那么为什么不能到达?
你需要configuration你的SSH连接。 Ansible ping模块的命名很混乱。 ping模块实际上build立了一个ssh连接来validationlogin的能力,并configuration了一个可用的python。
所以就像ping command可以告诉你到远程主机的networking连接正在工作, ping module告诉你Ansible能够在远程主机上运行命令。
看官方文档如何设置ssh连接到你的Vagrant框。
基本上你会需要这样的东西:
ansible-playbook --private-key=~/.vagrant.d/insecure_private_key -u vagrant -i .vagrant/provisioners/ansible/inventory/vagrant_ansible_inventory playbook.yml
对于特定的命令是这样的:
ansible --private-key=~/.vagrant.d/insecure_private_key -u vagrant ...