Recently I decided to stop bothering me with "standard" system administration and I switched to a more devops-oriented administration using Chef.

After a few days I found a very useful gem, knife-esx which is a Knife plugin to create and bootstrap new VMware virtual machines on the fly. I patched it and its dependency gem esx because it wasn't possible to set the number of cores per virtual CPU, but now it is so, to create a new virtual machine and bootstrap it you just need to type:

 knife esx vm create \
       --free-license \
       --esx-host <MY_ESXI_HOST> \
       --esx-templates-dir /vmfs/volumes/datastore1/esx-gem/templates \
       --vm-name <NEW_VM_NAME> \
       --guest-id ubuntu64Guest \
       --use-template ubuntu-12.04-x64_template.vmdk \
       --distro ubuntu12.04-gems \
       --vm-memory 512 \
       --vm-cpus 8 \
       --vm-cpu-cores 4 \
       -x <SSH_USERNAME> \
       -i ~/.ssh/id_rsa \
       --node-name <CHEF_NEW_NODE_NAME> \
       -r 'role[base],role[esx-vm]'

blog comments powered by Disqus