Thursday, August 29, 2013

Configuring a custom SysPrep file for AWS Windows Instanes

I needed to convert a Windows Server 2012 instance into an AMI so that it could be deployed as part of an auto-scaling configuration.

 

My domain already existed and so I simply needed to grab the existing Sysprep2008.xml file from

 

C:\Program Files\Amazon\Ec2ConfigService\sysprep2008.xml

 

And add in the following components under the respective sections.

 

Under the “Generalize” section.

 

    <component name="Microsoft-Windows-Security-SPP" processorArchitecture="wow64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

      <SkipRearm>1</SkipRearm>

    </component>

 

Under the “Specialize” section.

 

    <component name="Microsoft-Windows-UnattendedJoin" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

      <Identification>

        <Credentials>

          <Domain>MyDomain.LOCAL</Domain>

          <Password>password123</Password>

          <Username>sysprepaccount</Username>

        </Credentials>

        <JoinDomain>MyDomain.LOCAL</JoinDomain>

        <MachineObjectOU>OU=Session Hosts,OU=Servers,DC=MyDomain,DC=local </MachineObjectOU>

        <UnsecureJoin>False</UnsecureJoin>

      </Identification>

    </component>

 

I then copied the modified sysprep file back into C:\Program Files\Amazon\Ec2ConfigService\sysprep2008.xml overwriting the original template.

 

After that, I ran EC2Config as follows:

 

“Set Computer Name” – I may look into including my own custom naming convention at a later stage, but for the purposes of testing, this ensures my servers all have unique names.

 

 

“Shutdown with Sysprep” – Pretty obvious what this does.

 

 

Once Sysprep has run and the instance has just down, you can then create an AMI from the instance and start having fun with auto-scaling.

 

A couple of gotchas – if you have a password with any kind special characters within the sysprep file, EC2Config will crap out and report an error parsing EntityName.

Needs a little more investigation but I changed the password to something a little more straight forward and it worked no problem.

 

I’ll add a future post about my exploits with auto-scaling.

 

 

 

 

 

1 comment:

aws jobs in hyderabad said...

I get a lot of great information here and this is what I am searching for. Thank you for your sharing. I have bookmark this page for my future reference. Search aws jobs in hyderabad.

A little about Me

My photo
My name is Mitch Beaumont and I've been a technology professional since 1999. I began my career working as a desk-side support engineer for a medical devices company in a small town in the middle of England (Ashby De La Zouch). I then joined IBM Global Services where I began specialising in customer projects which were based on and around Citrix technologies. Following a couple of very enjoyable years with IBM I relocated to London to work as a system operations engineer for a large law firm where I responsible for the day to day operations and development of the firms global Citrix infrastructure. In 2006 I was offered a position in Sydney, Australia. Since then I've had the privilege of working for and with a number of companies in various technology roles including as a Solutions Architect and Technical team leader.