attachments/lrayl/media/windows-live-writer/orchestrator-system-center-integrations-_a48e/clip_image001_thumb.png

Orchestrator System Center Integrations Part 3 – Creating a VM based on a Template in VMM

Orchestrator System Center Integrations Part 3 – Creating a VM based on a Template in VMM

In Part 1 of my Orchestrator System Center Integrations blog, we setup the configuration for the Orchestrator Integration Packs for AD, Configuration Manager, Operation Manager and Virtual Machine Manager. In Part 2, we started using Orchestrator by creating a simple Runbook that created a computer account in a specific OU in AD. In Part 3, we are going to create a Template in VMM and using Orchestrator and deploy the template for the computer account we created in Part 2 to a VMM Cloud.

If you missed Part 1 and Part 2, they are located here:

 

Part 1 –

 

http://blogs.catapultsystems.com/lrayl/archive/2013/06/21/orchestrator-system-center-integrations-part-1-setting-up-the-integration-packs.aspx

 

Part 2 –

 

 http://blogs.catapultsystems.com/lrayl/archive/2013/06/21/orchestrator-system-center-integrations-part-2-creating-a-computer-account-in-an-ou.aspx

Since Windows 2012 R2 was released last week, I thought I would setup this section using Windows 2012 R2 Datacenter Preview. That in itself presented some challenges so it took more time to write this blog than expected. Anyways, the first thing we are going to do is create a new template based on the Windows 2012 R2 Datacenter Preview OS using the ISO download available on TechNet (http://technet.microsoft.com/en-us/evalcenter/dn205288.aspx). Then we are going to automate the deployment of the template using VMM.

 

There are multiple ways to create templates in VMM, this is just one of them. The goal is to have a Windows 2012 R2 Template that I can automate the deployment using Orchestrator.

 

Creating the Template in VMM

 

So to begin, I create a new VM using the Windows 2012 R2 Preview ISO media available on TechNet. Here is a screenshot of my Hardware Profile (I renamed the ISO file).

 

clip_image001

 

Select the Destination, Cloud and any other properties you want and create the template to install Windows 2012 R2. Cameron Fuller has a blog on the setup of Windows 2012 R2 here:

 

http://blogs.catapultsystems.com/cfuller/archive/2013/06/25/installing-the-windows-server-2012-r2-preview-release.aspx

 

So below, we see that Windows 2012 R2 installation is almost finished.

 

clip_image002

 

Then we create our admin password and login for the first time.

 

clip_image003

 

Next, make any configuration changes you want. I turn off IE Enhanced Security for Administrators, enabled Remote Desktop and change the time Zone to Texas time Smile.

 

 

clip_image004

 

After you make your customizations, run Sysprep from C:\Windows\System32\Sysprep folder. Make sure you select Enter System Out-of-Box Experience (OOBE), Generalize, Shutdown.

 

clip_image005

 

Next I grabed a copy of the .vhdx file for the Syspreped Windows 2012 R2 VM created, rename it, and place it in the library. When I setup my template in in VMM, I will specify this .vhdx file in the template.

 

clip_image006

 

As I run through the Wizard to create a new Virtual Machine template in VMM, I want to make sure I am using a common configuration for my hardware, I can always change it later.

 

clip_image007

 

For my OS Configuration, I have a RunAs account that I use for the local Administrator called VMM RunAs. To login to new VMs as the local Admin, the password for the RunAs account is used.

 

clip_image008

 

Another RunAs account I have in my Lab environment is called "VMM Join Domain RunAs Account". This account has permissions to join new computers to my LAB domain. You could also prompt for the account used to join the computer to the domain using Orchestrator.

 

clip_image009

Adding on to our Runbook

 

So in the "Orchestrator System Center Integrations Part 2 – Creating a computer account in an OU" blog, we created a Runbook that created a computer account in a specific OU. Continuing on, the first thing I will do is rename the Activities to something more meaningful from the Runbook created in Part 2.

 

 

clip_image010

Next, take a look at the activities for SC 2012 SP1 Virtual Machine Manager. There are quite a few of Activities in the VMM Integration Pack to use for your Runbooks. The one we are interested here is called Create VM From Template.

 

 

clip_image011

 

 

Now, drag the Create VM from Template Activity into the Runbook we have been working on and draw a line between "Create a Computer "Account in the Servers OU" and "Create VM from Template"

clip_image012

 

Next, right click on the Create VM from Templates, and select Properties, then click on the ellipse and select the Configuration for "SC 2012 VMM" we created in Part 1. If you receive an error, you will need to troubleshoot the integration. Possible issues include WinRM, Powershell Remote Execution, or the User Account used in the integration.

 

 

clip_image013

By default, Destination Type, Destination, Path, VM Name, Source Template and Cloud Capability profile are provided. However, there are a lot of other properties you can select from the Optional Properties by clicking on "Optional Properties…". You will either need to specify by Hard Coding the value or by Subscribing to it from Initialize Data or the previous Activity. Here is a screenshot of the Optional Properties you could use.

 

 

clip_image014

 

For Destination Type, I hard code "Cloud" because I want all VMs to run in one of the Clouds I have in VMM. When I click in Destination Type, there is an ellipse that I can enter in my choice to hardcode. There are only two options here; Cloud and Host. If you choose Host, you will also need to specify the path property. You could also subscribe to the what goes here but you would either need to enter in Host or Cloud in the Initialize Data Activity.

 

All I do here is click on Cloud and select OK.

 

 

clip_image015

 

For Destination, I do not necessarily know what Cloud I want to put the new VM into. So for Destination, I will have to subscribe to the data. Going back to the "Initialize Data" activity, I will place and entry for Cloud. The Clouds I have in VMM are Production, Management and Development.

 

On the Create VM from Template Properties, I click Finish; we will need to come back here so we can Subscribe to the Cloud after we have the information in the Initialize Data Activity.

 

On Initialize Data, I enter in a new parameter called Cloud with a data type of String. The String is going to be the name of the Cloud I want the VM place in.

 

 

clip_image016

 

Now, I can go back to the Create VM from Template activity, Right Click in the Property, and select Subscribe, Published Data.

 

 

clip_image017

 

When the Published Data window opens, I select the Initialize Data activity.

 

 

clip_image018

Now I can select Cloud from Initialize Data.

 

clip_image019

Now when I run the Runbook, I will be prompted for Computer Location for the OU, Cloud, Computer Description, and the Computer Name.

Moving on, we have VM Name. The VM Name is the name you will see in VMM. This property should be the same as Computer Name. So we need to right click and subscribe to Computer Name from Initialize Data.

 

 

clip_image020

 

For Source Template Name, I want to Hard Code in the template for Windows 2012 R2 Preview we created earlier. Here I select the ellipse and chose the "Windows 2012 R2 Preview Template" that we created earlier. If I had multiple templates, I could also create another entry in Initialize Data so I would be prompted for which template to use.

 

 

clip_image021

The next property we need to have because we are putting VMs in Clouds defined in VMM. Since the Clouds I have only support Hyper-V, I am going to hard code in Hyper-V here. If I wanted the VM to be created in VMware, I could choose ESX Server or if the Cloud supported Citrix XenServer, I could choose XenServer. Or if I wanted, I could prompt for the Cloud Capability Profile and create a new String for Cloud Capability Profile under Initialize Data. The Cloud and the Template used must also have the Cloud type listed or a failure will occur.

 

 

clip_image022

One property that is missing from the Create VM Template Properties in the Computer Name. We have the VM Name, but that is not the same as the Computer Name in VMM. We need to select the Optional Properties again and select the Computer Name property, then select OK.

 

 

clip_image023

 

Now we need to subscribe to the Computer Name string from Initialize Data so Computer Name property has a value.

 

 

clip_image024

We are also missing a Description of the VM. We have a description of what will be entered in Active Directory, but not a description in VMM. So again, we select Optional Properties, and choose Description.

 

 

clip_image025

Now we simply Subscribe to the Computer Description in Initialize Data for the Description property that will be displayed in VMM. this will also match the value in AD.

 

 

clip_image026

I did some testing with the template that was created earlier for Windows 2012 R2 Datacenter Preview and ran into some difficulties because of the Product Key Code. When I created a new computer using VMM, I was not having any issues because the key was in the OS Profile. However, when I tried using Orchestrator to deploy the template, it was not working correctly.

Typically what I do in my templates, for the OS Profile, is use the KMS Setup Keys available on TechNet here: http://technet.microsoft.com/en-us/library/jj612867.aspx. The KMS Setup Keys will also a new VM to complete the setup process, but you will still need a license for the OS or if you are using KMS, you can activate the VM through your existing environment.

But because Windows 2012 R2 Datacenter is not listed in the KMS setup keys, I had to hard code in the product key into Orchestrator that Microsoft Provided when I downloaded the ISO file for Windows 2012 Datacenter Preview.

 

Again, selecting Optional Properties, add in the product Key if you are using Windows 2012 R2.

 

clip_image027

 

Hard Code in the in the product key so the Property has a value.

 

 

clip_image028

When you create a VM from Template, the VM that gets created is stopped. There is an Activity to Start VM that we will add to the Create Computer from Template Activity.

 

In Orchestrator, add in a new Activity called Start VM into the Runbook and draw a line between Create VM from Template and Start VM.

 

clip_image029

In the properties for Start VM, select the SC 2012 VMM Configuration

 

clip_image030

The only property for the Start VM Activity is VM ID. Right click on VM ID and Subscribe to the VM ID property from the Create VM From Template Activity. Select OK, then Finish.

 

clip_image031

Finally, we are ready to test the Runbook. Select the Runbook Tester. Select Run from the Runbook Tester

 

clip_image032

Enter in the Computer Name, Computer Description, Computer Location, and Cloud; then select OK

 

clip_image033

Looking at the Log, we see the Computer account was created successfully

 

clip_image034

In Active Directory we see the Computer Account in the Servers OU

 

clip_image034[1]

Properties of the Computer Account have a Location Property

 

clip_image035

In VMM we see our new VM has a Status of Creating…

 

 

clip_image036

After a few min we can see that our VM was created successfully in Orchestrator by looking at the Log in the Runbook Tester. It took approximately 12 minutes to create.

 

clip_image037

And here is our new VM ready to go, and we can login to the domain.

 

 

clip_image038

Checking the properties of the VM we see that we are running a Windows 2012 Release Candidate Datacenter, joined to my lab domain.

 

clip_image039

Creating a VM from a Template using Orchestrator is a lot quicker than if you used VMM. We only need to provide a Computer Name, a Description, a Cloud and the Location for the location property in AD. If you were creating a VM from Template in VMM, you would have had a handful of wizard pages you need to go through. We now can tie our Runbook into Service Manager and you have an even simpler way to create new VMs.

 

Hopefully this all makes sense to you; if you have any questions, feel free to add in a comment below.

In Part 4, we will add in Alerts to SC 2012 SP1 Operations Manager for the various stages of the creation process.

3 Comments

  1. sanisan August 15, 2013
  2. Frank December 30, 2013
  3. Rahul Sharma December 31, 2013

Leave a Reply