«

»

May 29

Ideal CentOS minimal template for Automation

Ever try to build a CentOS image for use with automation or just simply use for templates in general with VMware? I can tell you from experience it can be very frustrating to have a great VM that you thought would work for cloning but when you actually test it nothing seems to work. With that in mind I thought I would create this post. In a very verbose manner we will walk through the following steps

Let’s start by going to vCenter -> select your DC -> Create a new virtual machine
01 Centos templatemp4

We are going to Create a new virtual machine
02 vSphere Web Client

Give it a name and select the data center you wish to create it in
03 vSphere Web Client

Choose the cluster
04 vSphere Web Client

Choose the storage *Note – if using for automation, put it on shared storage
05 vSphere Web Client

Select the compatibility mode *Note – you will not be able to choose any level higher than your supported vCenter/Host. It’s also important to know that if you choose 5.5 it will only be editable by the web client)
06 vSphere Web Client

Choose the Guest OS family – Linux, and a OS version. *Note – I recommend using RHEL even though there is a Cent option. If you choose RHEL you can then use customization specs within vCenter
07 vSphere Web Client

Go to VM Options tab -> Expand Boot Options -> Check Force Bios
08 vSphere Web Client

Now expand Advanced -> Edit Configuration
09 vSphere Web Client 1

Now we add the following 3 rows
isolation.tools.copy.disable FALSE
isolation.tools.paste.disable FALSE
keyboard.typematicMinDelay 200000
10 vSphere Web Client 2

Click Finish when ready
12 vSphere Web Client

Now power on the VM
13 Centos templatemp4

Go to the manage and connect the iso image for CentOS
15 Centos templatemp4

Launch Console
14 Centos templatemp4

In the BIOS settings make sure to set CD-ROM Drive in the boot options to first
16 Centos templatemp4

Now boot into your iso image
17 Centos templatemp4 1

Media check, I typically skip but can be handy if you have any corrupt data from your iso
18 Centos templatemp4 1

Installer is now running – click next
19 Centos templatemp4 1

Select your language
20 Centos templatemp4 1

Should be Basic Storage Device as the vmdm is what you will be installing to
21 Centos templatemp4 1

Warning about wiping data, since this is a new VM should not matter
22 Centos templatemp4 1

Choose a host name *Note with 6.5 the short name here is what it will use for the default Volume Group in the LVM configuration
23 Centos templatemp4 1

Configure Network
24 Centos templatemp4

Ensure that “Connect automatically” is checked
25 Centos templatemp4

Select your timezone
26 Centos templatemp4

Set your password for root
27 Centos templatemp4 1

Choose your disk layout, I select “Use All Space” in order to build a default LVM
28 Centos templatemp4 1

Are you sure…Yes write changes to disk
29 Centos templatemp4 1

After some time the install will complete and give you this reboot screen
30 Centos templatemp4 1

After the reboot is complete we login as root and update to the latest software components
Type yum update
31 Centos templatemp4 1

As that completes you will see a summary
Type y to continue with the updates
32 Centos templatemp4 1

Once that portion completes you will be prompted to continue with the RPM Key for installation purposes
Type y to continue
33 Centos templatemp4 1

Once installation of the updates completes now you need to install perl so that vmware tools can load properly
Type yum install perl
34 Centos templatemp4 2

Again a summary will appear
Type y to continue
35 Centos templatemp4 1

Install the piece for automation tools to detect information about the system
Type yum install dmi_decode
c65

Next let’s initiate the vmware tools install
37 Centos templatemp4 1

Mount the disk
38 Centos templatemp4 1

Now we go through the step by step commands *Note the [TAB] references the tab button as it will complete the file name or directory for you
Type mkdir /mnt/cdrom (this creates the directory)
Type mount /dev/cdrom /mnt/cdrom (this mounts the cdrom into that created directory)
Type cp /mnt/cdrom/VMwareTools[TAB] /tmp (this will copy the file to the /tmp directory)
Type umount /mnt/cdrom (unmounts the cdrom)
Type cd /tmp (takes you into the /tmp directory)
Type ls (verify file is there)
Type tar -xzvf VMware[TAB] (this will extract the files)
39 Centos templatemp4 1

Next we run the following commands to kick off the install of tools
Type cd vmware-tools-distrib
Type ./vmwareinstall.pl
Choose all the defaults during installation
40 Centos templatemp4 1

Once complete you will see the following on the screen
41 Centos templatemp4 1

Now that we have complete the installation of tools we have a number of steps that need to occur to make this streamlined for cloning
Type rm /etc/dev/rules.d/70-persistent-net.rules
Type y
Type vi /etc/sysconfig/network-scripts/ifcfg-eth0
42 Centos templatemp4 1

Move the cursor to the UUID row and type dd to delete it
Do the same for the HWADDR
43 Centos templatemp4

Type :wq in to save and exit the editor
44 Centos templatemp4 1

Now lets disable the firewalls that would prevent communication of any agents
Type chkconfig iptables off
Type chkconfig ip6tables off
Type echo 0 >selinux/enforce
Type vi /etc/selinux/config
45 Centos templatemp4 1

Type i to insert
Change the SELINUX= to disabled
Type :wq to save
46 Centos templatemp4 1

Your template is now ready for use!
Type shutdown -h now
47 Centos templatemp4 1

Now back to the vSphere client and either take a snapshot for linked clone or clone directly to a template
48 Centos templatemp4 1

3 comments

  1. Daniel Edwards

    Does this work with static IPs and VCAC6? Having a real problem getting the linked clone to pick up an IP after its provisioned. I used a customization spec and the adapter just gets set to DHCP. VCAC has an allocation for the IP under network profiles. It just nevers makes its way to the OS.
    Daniel.edwards@cdillc.com

  2. Daniel Edwards

    Does this work with static IPs and VCAC6? Having a real problem getting the linked clone to pick up an IP after its provisioned. I used a customization spec and the adapter just gets set to DHCP. VCAC has an allocation for the IP under network profiles. It just nevers makes its way to the OS.
    Daniel.edwards@cdillc.com

    edited the reply email

    1. Gary

      Daniel,
      Yes this works with vCAC and static IPs from the network profile. Couple of key steps though

    2. First you need to classify the CentOS template as a RedHat template in vCenter. The reason for this is we don’t support customization specs to be applied to Cent yet.
    3. Next you create a Linux customization spec in vCenter, make sure to define a static IP in the customization spec so we can overwrite with vCAC.
    4. Finally on the blueprint use that customization spec by name and yes it’s case sensitive.
    5. Then on the blueprint use that customization spec by name.
    6. Ta Da, you will now have static IP assignments working!

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>