Vagrant with Ansible for Windows VM

I try to run Vagrant with Ansible on my Mac to create and provide a Windows 7 virtual machine. I can "disdain" when I do not call Ansible in the Vagrantfile.

I am using the following playbook.yml

--- - hosts: all tasks: - name: run win ping win_ping: 

When I add irreplaceable code to my Vagrantfile, I get the following error

 GATHERING FACTS *************************************************************** failed: [default] => {"failed": true, "parsed": false} /bin/sh: /usr/bin/python: No such file or directory 

For me, this error means that he cannot find Python because he is looking for Python as if it were a Linux machine.

Separately, I launched

 ansible windows -m win_ping 

where windows is the IP address of the virtual machine created by Vagrant, so I suspect the problem is not with Ansible, but with the way Vagrant calls Ansible.

Has anyone tried Vagrant + Ansible for a Windows virtual machine? Is there something obvious that I'm missing (maybe an option to switch to Ansible)?

I am using Vagrant version 1.7.2 and Ansible version 1.8.3

+5
source share
2 answers

With the ability to create a Windows window (either Vagrant, VM, or a real machine), configuration is much more important in the first place. Before you create your tutorial, you must have the correct configuration.

Having a Windows window controlled by Vagrant, your group_vars/windows-dev configuration file should contain something like:

 ansible_user: IEUser ansible_password: Passw0rd! ansible_port: 55986 # not 5986, as we would use for non-virtualized environments ansible_connection: winrm ansible_winrm_server_cert_validation: ignore 

Be sure to insert the correct credentials and select the correct port for ansible-port . When working with Vagrant, you can get the correct port from the log messages created by Vagrant after vagrant up . In my case, it looks like this:

 ==> default: Forwarding ports... default: 5985 (guest) => 55985 (host) (adapter 1) default: 5986 (guest) => 55986 (host) (adapter 1) 

My Vagrantfile can be found here if you are interested. It uses the Microsoft Edge image on Windows 10 Stable (14.xxx) from https://developer.microsoft.com/en-us/microsoft-edge/tools/vms .

Now the win_ping module should work - provided that you have completed all the necessary preparation steps on your Windows box, in the center of which executing the ConfigureRemotingForAnsible.ps1 script (for more information, see the Finished Windows Ansible ready chapter in this blog post ):

 ansible windows-dev -i hostsfile -m win_ping 

Only if it gives you SUCCESS should you start creating your play.

+1
source

In my Windows boot book, I set this in the header:

gather_facts: no

0
source

Source: https://habr.com/ru/post/1213831/


All Articles