Deploying Windows Server with Foreman in vSphere

In Foreman Provision: A Comfortable Resource Management Tool for Foreman we learned how to deploy CentOS Linux Hosts with Foreman. Now what if we instead need to deploy Microsoft’s Windows Server? Read on for a detailed walkthrough.

Despite the fact that Foreman was primarily built to deploy free operating systems like GNU/Linux and *BSD you can make use of vSphere VM templates to deploy new Windows systems.

vmware-vsphere

Technical Requirements

In order to start deploying Windows we need to install additional Foreman packages for VMware vSphere Compute Resource support.

Foreman VMware Support

Now we see „VMware“ provider support has been installed.

For further steps we need the following setup:

  • VMware Version 5.5.0 Build 2414847
  • vSphere template containing Windows Server 2008 R2
  • A vSphere/ vCenter user that has sufficient access to deploy VMs via vCenter

Preparing Windows Deployment

The first step to prepare Windows deployment is to add a new compute resource of type „VMware“:

Adding Compute Resource

 

Here we make use of Fog, a library that provides management of virtual resources for private and public IaaS/SaaS (a.k.a. Cloud) providers. With the most recent release of Foreman, we get Fog 1.32 which is also listed in the Foreman 1.9 changelog. The VMware customization feature modifies the guest operating system of a newly created virtual machine to prevent having hosts in a network that have the same network configuration, SSID, serial number and so on.

The next step is to add a Windows operating system and a compute resource image in Foreman.

New Compute Resource Image

When creating the image you might have noticed the checkbox with the label „User data“. User data is a Foreman provision template that Fog will translate into an XML tree that matches VMware’s customization specification. Create a new provision template with the following content, set the type „user_data“ and associate it with the Foreman Windows operating system.

Finally the Windows operating system needs to be associated with the newly created user_data template, too.

With this being done you will be able to create new hosts (VMs) in VMware and specify the VMware template (here: „winabechtoldt-8-TEMPLATE“) as image. The compute/“cloud“ library Fog that is used by Foreman will create a new VMware VM, clone the template disk (our image), boot the VM and initiate all the Windows-specific actions/customizations:

  • NIC IP configuration
  • workgroup/domain join
  • activate a license using the product ID (serial number)
  • triggers finish/post-install commands (install Puppet & tell Foreman that the build has completed)
  • etc.

In case you need to deploy Windows on bare metal you may want to use one of the widely used image deployment concepts in combination with Foreman. You’d need to let Windows start some scripts like the PowerShell script puppet-windows.ps1 that installs Puppet.
However, deploying Windows on bare metal might be handled in a future blog post. 🙂

Have fun deploying Windows using Foreman!

Credits

Thanks to the people that have contributed the following articles and sources:

We’re hiring!

Looking for a change? We’re hiring DevOps Engineers experienced with NodeJS, Git, Jenkins, Puppet and of course Foreman. Apply now!

Get in touch

Interested in automation and virtualization? Check out the Data Center Automation section on our website, call +49 721 619 021-0 or drop us an email.

comments powered by Disqus