locked
How to inject hostname in Centos6 template before start VM RRS feed

  • Question

  • Hello guys.

    I have the following setup:

    2012 Failover cluster with a Centos 6 template (vhdx).

    I use a PS script to create a new VM in the cluster, then I copy the template vhdx to the new machine's folder. I start the VM, I create a new sshsession using import-module SSH-Sessions, I connect to it and run bash commands to change the hostname in /etc/sysconfig/network with the variable that comes from PS. 

    The next bit is to restart the machine to get the new hostname, then I connect to it again to run a bash script to join the Centos machine to windows domain.

    In order to have all this I need to wait two time for the machine to boot up (the first boot and then the second to join it).

    I would like to get rid of the seconf wait time to boot.

    If I were to use VmWare Esxi, there is a method to inject some parameters directly to the template (like hostname, IP and so on). Is there something the same that I could do using PS or something else Microsoft provides?

    I have to mention that in order to be able to connect to the new machine when boots up, in the template I have installed the latest LIS.

    Thank you.

    Gabriel

    Wednesday, August 3, 2016 10:03 AM