Multi-machine ansible setup with vagrant on windows

爱⌒轻易说出口 提交于 2019-12-05 21:51:04

To answer my own question: the problem was resolved by upgrading ansible and importing the ssh keys of the other machines in Provision.sh.

# fix permissions on private key file
chmod 600 /home/vagrant/.ssh/id_rsa

# add web/database hosts to known_hosts (IP is defined in Vagrantfile)
ssh-keyscan -H 192.168.51.4 >> /home/vagrant/.ssh/known_hosts
ssh-keyscan -H 192.168.52.4 >> /home/vagrant/.ssh/known_hosts
chown vagrant:vagrant /home/vagrant/.ssh/known_hosts

# reload ssh in order to load the known hosts
/etc/init.d/ssh reload

Thats a really long question problem. Ansible cant figure out the dns "ssh: Could not resolve hostname web1: Name or service not known"

Option 1

I like to simplify i boot my vagrant vm with static ip vm.network :private_network, ip: "xxx.xxx.xxx.xxx" and i edit my ansible host file

provsioning/hosts/dev_hosts

[webservers]
web1     ansible_ssh_host=xxx.xxx.xxx.xxx

[dbservers]
db1     ansible_ssh_host=xxx.xxx.xxx.yyy

Option 2

Use DNS or hostsfile

Hope that helps

jonashackt

Using "normal" Ansible modules to manage Windows boxes isn´t possible. Instead you have to use one of the windows modules. That´s the same for ping. It tries to connect via SSH to the Windows box, which doesn´t work.

Like skinnedknuckles already said, Ansible uses native Powershell remoting (and WinRM) instead of SSH to communicate with a Windows machine. So the win_ping module is the right way to do a ping with Ansible onto a Windows box:

ansible -m win_ping -all -i path-to-hosts

I assume you prepared your Windows 8 VM, like the docs are describing!?! If not, there´s this blog post explaining how to do all the steps incl. Vagrant setup with winrm connectivity in quite compact form.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!