Thursday, March 17, 2011

ESX Scripted Install – part 3/4

Last post we worked on how to pass parameters to the installer.

Now it’s time for the customization you can make after the Operational System is installed.

The %post section will carry on all the commands you want to execute after your ESX has been installed, that means the ESX is loaded and all the ESX’s commands are available too you.

The installation sequence is something like:
1 – installer loads
2 - %pre section loads and you input your parameters
3 – installation occurs based on the %pre section information.
4 – installer executes the commands on %post section
5 – Server reboots

Did you realized the power of this section ?!!?!

You can run all the commands you normally do when configuring your host after installing it, like
esxcfg-firewall command to open/close ports
esxcfg-auth command for the authentication settings

Anything you normally do on a host session. The command syntax is just the same.

So, how to use the %post section ?

Start with the following line after all the %pre section commands
%post --interpreter=bash

Then just place the commands, one per line.

But the trick I can show you, is that you can also copy files to the host, may be the sshd_config file, with your already configured SSH options or even coping rpm packages for agents installations.

How does it work ?

- first you will need to create a folder with all the required files and packages you want to use.
- Then burn a CD with the ESX installation and your new files (we will cover this process on the next post)

Now that your CD is ready with the files you need, let’s configure the %post section

First you will need to mount the cd-rom on the system
mount /dev/cdrom /mnt/cdrom

them you can just copy the files from the cd to the system, like
cp /mnt/cdrom/Custom/sshd_config /etc/ssh/sshd_config

or installing the RPMs on your system, like
rpm –ivh /mnt/cdrom/Custom/agent.rpm

Here’s just a sample of a script to help you start your own

************************************************

%post --interpreter=bash

#mount CDROM
mount /dev/cdrom /mnt/cdrom

#enabling ssh on firewall
esxcfg-firewall -e sshClient

#configuring ssh
mv /etc/ssh/sshd_config /etc/ssh/sshd_config.old
cp /mnt/cdrom/Custom/sshd_config /etc/ssh/sshd_config
chmod 600 /etc/ssh/sshd_config

#unmont cdrom
umount /mnt/cdrom

************************************************


I bet your are anxious to get it working ; )

No comments:

Post a Comment

Who am I

My photo
I’m an IT specialist with over 15 years of experience, working from IT infrastructure to management products, troubleshooting and project management skills from medium to large environments. Nowadays I'm working for VMware as a Consulting Architect, helping customers to embrace the Cloud Era and make them successfully on their journey. Despite the fact I'm a VMware employee these postings reflect my own opinion and do not represents VMware's position, strategies or opinions. Reach me at @dumeirell

Most Viewed Posts

Blog Archive