I also want to mention that this was my first time using Puppet and though there are some videos and guides, it still may not be trivial for new users on what is needed. I thought I walk you through the steps I took to quickly stand up several ESXi 5 hosts in minutes using Razor.
Step 1 - Install Ubuntu Precise (Ubuntu Server 12.04 LTS) which will be your Razor server
Step 2 - For a clean installation of Precise, you will need two additional packages: git and make as well as Puppet. Using the following command, it will pull down the latest updates as well as adding the apt.puppetlabs.com repot to install Puppet:
Note: Thanks to Nan Liu for this quick snippet!
Step 3 - You will need to change the ownership of puppet module directory by running the following command:
chown -R puppet:puppet /etc/puppet/modulesStep 4 - To verify that you have successfully installed Puppet 2.7.14, you can run the following command which should return you the version:
puppet --versionStep 5 - Now you will install the Razor module using puppet by running the following command:
puppet module install puppetlabs/razorStep 6 - Next you will initialize and setup Razor by running the following command (this will take a few minutes to complete):
puppet apply /etc/puppet/modules/razor/tests/init.pp --verboseStep 7 - Now to verify that Razor has been properly installed, we will go ahead and run it and it should return you the usage options. The path to the razor command is under /opt/razor/bin/razor and we will go ahead and add it to our system path so we can just run "razor". Run the following commands:
export PATH=$PATH:/opt/razor/bin
razor
Step 8 - Finally we also need to ensure that the Razor web services is running, this is currently a known issue which hopefully will be fixed very soon. By default, the web service should automatically start by itself, but currently you need to manually start it. You can run the following commands to verify the status and then start it:
/opt/razor/bin/razor_daemon.rb statusStep 9 - When you power on your host, Razor will need to load a micro-kernel (MK) image for it to register with the Razor server and provide information about your bare metal host or VM. The following command will download and import the MK ISO image into Razor:
/opt/razor/bin/razor_daemon.rb start
wget https://github.com/downloads/puppetlabs/Razor/rz_mk_dev-image.0.8.8.0.isoStep 10 - Razor automatically comes with a TFTP server, you just need to have a DHCP server which will forward the request to the Razor server. I will assume you have or know how to setup a DHCP server and here is an example of what my DHCP configuration looks like for several "virtual" ESXi Shells which I plan on provisioning with ESXi 5:
razor image add mk ./rz_mk_dev-image.0.8.8.0.iso
Note: You just need to set the next-server stanza to your Razor server and the filename to "pxelinux.0" which exists on Razor server
Step 11 - To verify we have no nodes that have registered with Razor, we can run the following command:
razor nodeStep 12 - To deploy ESXi 5 on our hosts, we will need a copy of the ESXi 5.0 ISO. In this example I am importing the latest ESXi 5.0 Update 1 image using the following command (you will need to download and upload the ISO to your Razor server via SCP/WinSCP):
razor image add esxi VMware-VMvisor-Installer-5.0.0.update01-623860.x86_64.isoNote: You will notice the type for the image is "esxi" versus "os" if you are planning on installing regular guestOSes.
Step 13 - Next we will create a Model which describes an ESXi 5 install and it's configurations. You will need to make a note of the UUID of the ISO we just uploaded from the previous step. Run the following command to create the model:
razor model add template=vmware_esxi_5 label=install_esxi5 image_uuid=5JC9GT8GToMak0DD3UivkeNote: You will also be asked to fill out a few properties such as the license and password for your ESXi host as well as the network information. If you are interested in the kickstart that is being used for the ESXi deployments, you can take a look at /opt/razor/lib/project_razor/model/esxi/5/kickstart.erb. If you would like to adjust the kickstart file, be sure to take a look here.
Step 14 - Okay, we are almost done! Now we just need to create a policy which binds the model to some set of attributes, such as the tags on our ESXi hosts that we wish to build. In my lab, I created a few vESXi hosts using steps found here and then creating a few Linked Clones so I did not have to waste any storage space using this script here. If you are using a vESXi host, by default you will get the vmware_vm tag which is what our base our policy on. Run the following command to create the policy:
razor policy add template=vmware_hypervisor label=install_esxi5 model_uuid=2w1QEGbkoXDELc6ndXb13A broker_uuid=none tags=vmware_vm enabled=trueNote: You will need the UUID of the model you just created which is highlighted in blue in the previous screenshot when creating the policy.
Step 15 - We can check our policy and confirm there are no nodes registered to Razor again, by running the following commands:
razor policyStep 16 - Now you are ready to power on your hosts and they should automatically get an IP Address from your DHCP server and forward your request to Razor and perform an iPXE boot.
razor node
Step 17 - Once the hosts have booted up the MK image and register with Razor, you should be able to run the following commands to see the nodes and their states:
razor policyAs you can see from the screenshots, I have 5 nodes that have registered and 4 of them are already in the postinstall process and the ESXi installation should be completely very shortly. If you head over to your hosts, you see that ESXi is completely installed and ready for use:
razor policy active
So there you have it, you can quickly provision from bare metal to a fully functional working ESXi 5 hosts literally within minutes (after the config setup of course). I still think there could be some improvements on the CLI help options (though Razor is still in beta), it was not always intuitive on the options for the commands and luckily I had Nick's video and the Wiki to help out with the options. All in all, Razor was very easy to use (especially for a first timer like myself) and though I was not able to get the vCenter Server modules to work ... since they haven not been released yet ;). I am really looking forward to seeing those modules get released soon by Puppetlabs.
If you are interested in learning more about Razor, I highly recommend you check out Nick's blog here as well as the Razor project's Wiki on Github here and help provide feedback or even contribute code back to the project. Great job again Nick and team!
















Once deployed, can puppet manage ESXi configuration, or do we still need to rely on host profiles?
ReplyDeleteThis is a great question, is there any feedback on this?
DeleteDude, you rock man !!!!!!
ReplyDeleteHi, sorry but I cannot get the following to work
ReplyDeletedistro=$(lsb_release -i | cut -f 2 | tr "[:upper:]" "[:lower:]")
release=$(lsb_release -c | cut -f 2)
cat > /etc/apt/sources.list.d/puppetlabs.list <<
EOFAPTREPO
deb http://apt.puppetlabs.com/${distro}/ ${release} main
EOFAPTREPO
I'm having to use sudo for apt-get etc
but this line
cat > /etc/apt/sources.list.d/puppetlabs.list <<
just produces -bash: syntax error near unexpected token `newline'
is there something wrong with the insered text?!?!
Could be that puppet has changed their url structure, but if you change this:
Deletedeb http://apt.puppetlabs.com/${distro}/ ${release} main
to this: (it'll be in /etc/apt/sources.list.d/puppetlabs.list, you don't need to run the script again if you have already)
deb http://apt.puppetlabs.com/ ${release} main
It'll work. So after the above:
apt-get remove puppet puppet-common
apt-get update
apt-get -y install puppet
And it'll install correctly, at least it did when I did it ;)
It should look like the following:
ReplyDeletedistro=$(lsb_release -i | cut -f 2 | tr "[:upper:]" "[:lower:]")
release=$(lsb_release -c | cut -f 2)
cat > /etc/apt/sources.list.d/puppetlabs.list << EOFAPTREPO
deb http://apt.puppetlabs.com/${distro}/ ${release} main
EOFAPTREPO
Cheers Will, that's helped somewhat however when I do apt-get update I get the following
ReplyDeleteW: Failed to fetch http://apt.puppetlabs.com/ubuntu/dists/precise/main/binary-i386/Packages 404 Not Found
E: Some index files failed to download. They have been ignored, or old ones used instead.
is this supposed to happen, is it somethig to worry about?
This comment has been removed by the author.
ReplyDeleteThis comment has been removed by the author.
DeleteThis comment has been removed by the author.
Deletegot to say this razor thing is a proper ball_ache.
Delete2 days. It's like pulling teeth.
got a little further with http://purevirtual.eu/2012/07/02/how-to-get-started-with-razor-and-puppet-part-1/
blog, but again it's very precise, devaite from the setup and it just doesn't work.
upto the point now of adding a model.
But alas more problems with syntax or somethine
tried
razor model add template=vmware_esxi_5 label=install_esxi5 image_uuid=2zDnGbfKRXf82XskyKt0pZ
and get the following
[Model] [add_model] <-Must Provide: [The model template to use for the new model.]
~Loosing the will to live....
I thought it was supposed to be easy install
Hi, link bust
ReplyDeleteLinked Clones so I did not have to waste any storage space using this script here.