How to create a Linux VMware Template

Hi there,

This has been very painful and frustrating.  So I am very happy I figured it out and can share it with you!  I hope that this helps you avoid the fuss I had.

Things to gather

You will need the media – Centos 7 in my case and uploaded where you can find it easily.  Incidentally I used Centos 7.0 and vSphere 5.5 U2 and everything patched to current (updated for vSphere 6.0 and Centos 7.0 1611).

Steps – Install

  • You need to create a VM of the type Redhat Enterprise 7 64-bit.
  • Do a basic Centos 7 install. I kept all the defaults, but had to confirm the disk, pick the right TZ, and add a good root password.  BTW, when you do the TZ, also enter Network and toggle it on – you should see a DHCP address.
  • Update the OS with the following command.

yum update

I had some issues in that networking did not work.  There were two things wrong – NETWORKING=YES did not exist and ONBOOT=No did exist. You can find out more on this subject in this article.

Configure

  • You should do a copy and paste of this long command and execute it at the command prompt:

rm -f /etc/redhat-release && touch /etc/redhat-release && echo "Red Hat Enterprise Linux Server release 7.0 (Maipo)" > /etc/redhat-release

  • we need to add a few typical things to the OS.

yum install wget

yum install bzip2

yum install perl

yum install net-tools (likely already installed)

Crazy Stuff

It is possible that with 1611 of 7.0 this section is not needed.  I did work through it and things were ok, but stuff was already in place so that makes me think it is not needed but will need to test.

certs

  • You should copy them to /tmp
  • Now we need to load those certs.

rpm –import /path/key_name.pub

  • Now create a text file

/etc/yum.repos.d/vmware-tools.repo

  • With the following contents

[vmware-tools]

name=VMware Tools

baseurl = http://packages.vmware.com/packages/rhel7/x86_64/

enabled = 1

gpgcheck = 1

  • This file and contents will look like below.

filePlus

  • We may, or may not need to install the open-vm-tools package.

yum install open-vm-tools (likely already installed)

  • Now we need to load the package that will do customization.

yum install open-vm-tools-deploypkg (something newer likely already installed so this step not needed)

This should look like the below image.

deploypgk

  • The certs we installed is what lets it be installed successfully.

Test Time

You should be able to turn the VM into a template and deploy from it successfully.

success

Note about how the VM name is test7, and the DNS name is test7.dglabs.com.  For so many tests the DNS name said centos.tmpl as it was the template name and wasn’t being updated.

Further Customization of your Linux Image

Just like I do a lot of tweaks to my Windows if you are a Linux Admin you would do the same.

You can find a really good long list of tweaks in this article.

You can find a good short list of tweaks in this article.

At this time I am not using any of these tweaks but when I do I will update this section of the article.

Miscellaneous Information

Perl Missing

If your deploy from template is not successful, like mine was, meaning that the template name remained and the VM name was not taken by the VM, you should check the following folder and file for clues.

customizationLog

I found in mine:

deployment result = 127

Which means Perl is not installed (so I had to update this article again!)

Missing Certificates

If you try and install the deploypkg and get an error like below you are missing the VMware certs.

deploypkg

How to get the certificates to your VM?

I had problems with this, so I used wget.  Which is why I added it to the list above!  And that worked great.  See below for an example.

wget

Links

None of these alone helped.  But bits of all of them helped a lot!

Serverfault – http://serverfault.com/questions/695043/issues-customizing-a-rhel7-vm-deployed-from-a-template-on-vmware

Serverfault – http://serverfault.com/questions/653052/from-vsphere-5-5-deploying-centos-7-from-template-ignores-customizations

Lone Sysadmin – http://lonesysadmin.net/2013/03/26/preparing-linux-template-vms/

VMware Centos OS 7 doc – http://partnerweb.vmware.com/GOSIG/CentOS_7.html

VMware KB article on installing deployPkg – http://kb.vmware.com/kb/2075048

Summary

With this info you should be successful in building out a Centos template for use in your VMware environment and without all the issues that I had.  I am not a linux guy so I might have more info here in this article then necessary but I can tell you it works!

Thanks and have a great day!

Update:

  • 1/11/17 – doing this with vSphere 6.0 U2. I also used the Centos 7 1611. Added a bit of detail above to help out.
  • 8/12/15 – Saw this great article for doing something similar in Red Hat.

Michael

=== END ===

 

Tagged with: ,
Posted in How To

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s

%d bloggers like this: