Vagrantfile

This Vagrantfile doesn't look too dissimilar from the ones we have been using to launch Linux hosts:

# -*- mode: ruby -*-
# vi: set ft=ruby :

API_VERSION = "2"
BOX_NAME = "StefanScherer/windows_2016"
COMMUNICATOR = "winrm"
USERNAME = "vagrant"
PASSWORD = "vagrant"

Vagrant.configure(API_VERSION) do |config|
config.vm.define "vagrant-windows-2016"
config.vm.box = BOX_NAME
config.vm.synced_folder ".", "/vagrant", disabled: true
config.vm.network "forwarded_port", guest: 80, host: 8080
config.vm.communicator = COMMUNICATOR
config.winrm.username = USERNAME
config.winrm.password = PASSWORD

config.vm.provider "virtualbox" do |v|
v.memory = "4048"
v.cpus = "4"
v.gui = true
end

config.vm.provider "vmware_fusion" do |v|
v.vmx["memsize"] = "4048"
v.vmx["numvcpus"] = "4"
end

end

As you can see, we are replacing references to SSH Vagrant. We will be using the Windows Remote Management (WinRM) protocol, as well as Ansible, to interact with the virtual machine. By default, the config.vm.communicator is SSH, so overriding this with winrm means that we have to provide config.winrm.username and config.winrm.password.

Also, we are instructing Vagrant not to attempt to try and mount our local filesystem on the virtual machine, nor to add any additional IP addresses or network interfaces; instead, it should just forward the port from our localhost machine to the host.

Finally, we are mapping port 8080 on our local machine to port 80 on the Windows host; more on that later in the chapter.

We can launch the host using one of the following commands:

$ vagrant up

This will use VirtualBox, or we can use VMWare by running:

$ vagrant up --provider=vmware_fusion

The Vagrant box we are using is several gigabytes in size so it will take a little while to download, but once downloaded you should see something like the following output:

Once the machine has launched, you will find that your virtual machine has opened a window and that the Windows desktop is accessible, as follows:

Just minimize this window for now as we will not be interacting with Windows directly. Closing the window may suspend and power down the virtual machine.

Now that we have our Windows host up-and-running, we need to install a few supporting Python modules, to allow Ansible to interact with it.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.223.114.142