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.

Mahmoud Magdy

Geek and Microsoft Exchange Server MVP, Solutions Architect at Ingazat Information Technology, Father and in deep love with my wife nad daughter, Aikidoka and have Aikido Green Belt so watch out ;).

mahmoud-magdy has 9 posts and counting.See all posts by mahmoud-magdy

Pin It on Pinterest