Skip to content

Creating VMs on ESX using scripts and cobbler

by on November 19, 2013

Well, I’m a simple bash scripts guy…

I know this could be done in much better and sophisticated way, but it is good enough for me (so far)

What you need:

  • ESX hosts (I have 5.1)
  • Cobbler – I was just able to make it work. I have Centos 6.3 in its repository.
  • Management Linux server with ssh capabilities to the ESX

What I do is the following:

  1. Go to the ESX and create the VM with some default parameters
  2. Wait some time for the VM to be created (5-10 seconds)
  3. Go to the ESX and get the MAC of this new VM
  4. Insert a new system to Cobbler
  5. Go to the ESX and power on the new VM

The flow to create the VM is simple:

  1. mkdir – create a folder with the VM name on the datastore
  2. vmkfstools – to create a vmdk under the folder
  3. echo – to create the vmx config file with default parameters
  4. vim-cmd solo/registervm – to register the new created vmx config file
  5. vim-cmd vmsvc/getallvms – to get the new created VM ID
  6. vim-cmd vmsvc/power.on – to power on the new created VM

and the scripts i have (i took from the web and modified to my needs. I’ll add the source later):

  • cre_vm.sh – an envelop script, running from the mgt linux and ssh to the esx
  • create_vm.sh – a script with VM CLI commands to create the VM – runs from within the ESX
  • cobbler_system_add.sh – a script to add system to cobbler

The scripts seems to be large as they have to get the right parameters (Also – I put them on other posts as I couldn’t find a nice way to embed them within this post).

Other notes:

  • I have an NFS Server where i put all my scripts. the ESX host also see the same scripts with the same path.
  • I have multiple disks for each ESX server – not using a centralized storage – so the datastore location is simple
Advertisements

From → Uncategorized

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: