Home > Cloud, Opalis, SCVMM, System Center > Automating #Linux Machines #provisioning on #Microsoft Hyper-v #Cloud using #opalis #hyperv

Automating #Linux Machines #provisioning on #Microsoft Hyper-v #Cloud using #opalis #hyperv

I was assigned the task by one of my customers to automate their Linux machines provisioning on their Hyper-v cloud they are running, they still evaluating the Hyper-v Cloud capabilities, and they were wondering if they can automate the Linux machines provisioning into Hyper-v Servers.

They currently still evaluating it, so the process for the request and automation still not clear in their mind, but the question and request was simple, we want to automate the process of copying and configuring the machine, specially that they are running lots of Linux virtual machines.

the setup:

– 2 Hyper-v nodes running in cluster, each with 128 GB of memory, SCCM,SCOM, SCVMM 2008 R2 SP1, DPM 2010.

– request will come from a help desk or purchasing system, this is not clear yet.

before we start here is some notes for Microsoft guys working on that:

– I spent couple of days trying to figure out how sysprep can be done on the Linux machines and how to script it, the important note that Linux doesn’t has SID related information bounded to the machine, so copying the machine and renaming it will bring a totally new machine to the cloud. reference here.

– the machine name for Linux can be placed and configured in several places, keep in mind that if you used the command hostname to set the Linux machine host name it will be changed to the default name after the restart, to set it permanently, you will need to set the host name on /etc/sysconfig/network file.

– to execute commands remotely you will need to SSH on the machine.

now let us rock n roll:

I have no experience on Linux scripting so steps mentioned here are just guidelines and placeholders for others to use and kick off their implementations, however I don’t claim that those are the best way to do it.

the workflow you will configure will require the following:

– Create a template Linux virtual machine by creating a normal machine on any hyper-v Host.

– Install the Linux Integration components for Hyper-v, the main factor to note that you will need to install the development tools on the machine so it can successfully compile the source.

– after the integration tools installation you will need to assign a static IP to the machine (this will be used by Opalis later to SSH to the machine and run the configuration commands).

– Shut down the machine, from the SCVMM 2008 R2 admin console, copy the virtual machine to the library (if the hyper-v hosts located in different forest or DMZ this can be done by copying it).

now let us start:

– Install Opalis, best video can be found here.

– Import the SCVMM 2008 R2 Integration pack.

– Create the provisioning work flow as following:


the work flow will do the following:

– Create a random name that will be assigned to the machine, this is just a placeholder, the machine can be retrieved from text file, SQL DB..etc


– Create a VM from the VM template from the SCVMM 2008 R2 Server, and assign the name generated by the previous task to it, the name will be Linux-randomtextvalue


to assign the name linux-randometextname, in the vmname field you can pass the results of the previous task by typing, linux- then right click in the field and choose subscribe and choose published data and choose random text results from the previous step.

– the next step will get the vm, make the name as the name linux-randometextname same as previous step.

-the next step will start the vm, and pass the VM ID retrieved by the “Get VM” task, since this task requires VM ID, use the subscribe and published data to pass the VM ID from the “Get VM” Task.

– the link between the “start VM” and next SSH command will wait for 300 seconds or 5 minutes to allow the machine to fully start.

– the next ssh command will ssh to the static IP of the machine, and change the name by altering the file /etc/sysconfig/network and searching it for the default name “localhost.localdomain” and change it with the random text results:


the command will be : sed -i ‘s/localhost.localdomain/Linux-{Randome Text from “Generate VM name”}/g’ /etc/sysconfig/network

– the next step will configure the machine to use DHCP commands, same SSH step the command will be: sed -i ‘s/none/dhcp/g’ /etc/sysconfig/network-scripts/ifcfg-eth0

– the next SSH command will restart the VM to apply the settings.

and you are done.

again you can play with the workflow and create you own flow, there is some guides on the internet to automate the request that came from SCSM into Opalis..etc but this article to give you an idea about how generally the Linux machine configuration will be done.

  1. April 24, 2011 at 1:03 am


    We do this (and have done) for some time on a VMware environment and have some generic Unix-side scripts that might be useful if you want them, really just to bootstrap the first-boot process.

    If you’re happy with what you’ve got, one thing it looks like you are missing is stripping out the SSH private key from the template VM. If you don’t do this there is a security risk. I’d also recommend removing the network config and letting Linux re-generate the config itself. There’s a lot of info on these topics in the VMware area and it’s all generic enough to use on

    Another thought if you want the interaction between the VMs is you could simply use an NFS share on the provisioning machine and drop a config file there that it could pick up to get settings like VM name, IP address etc. If you want to avoid any interaction/config via commands/NFS shares the first-boot script could also simply set it’s hostname and other properties to the one supplied by DHCP/DNS lookup.


  2. April 24, 2011 at 12:07 pm

    Hi Steve,
    I won’t claim that this is the ultimate solution, I am not a Linux guy and spent 3 days trying to figure out the SID trick until I knew that Linux doesn’t have similar thing.

    this is just a POC for the idea, the original idea that they came with that they cannot auto-provision Linux machines on hyper-v, with the above workflow now they can.

    lots of scripts and modifications can be added, I totally agree, just add/remove as you want starting from the above and going up.

    the SSH key looks very important, I have seen it somewhere but forgot to add it, that will be a very important step to do.

  3. Mohamed Fawzi
    April 27, 2011 at 12:42 am

    good work

  4. April 27, 2011 at 9:36 am

    ya basha sha7’betet 2alamak ta7’tet el blogati

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: