How to get started with Razor and Puppet – Part 2

Please read the comments, updates there!
Razor has gotten a CLI and API update, making some of the commands shown here not work correctly. If you come across something that doesn’t work, please look at the Razor wiki for help regarding that command.

Welcome back! Now that we have gone through the basic setup of a Ubuntu master server, installation of Puppet, Razor and a DHCP server, you’re ready to get into the most exciting part, automated deployments!

Razor includes a tftp installation as well, so we have everything that’s needed to get our deployments up and running. Let’s try it, start another VM on the same network as the Razor/Puppet server, and you should see that it gets an IP, and after that you should see the following screen on your VM:

However, when it’s trying to boot you’ll encounter this message:

What gives? No OS? Oh that’s right… Let’s dive in and see how we can configure this awesome tool that is Razor to actually serve up some images to our deployment hungry servers!

First, verify the status of the Razor service, and if it’s not running, start it. While you’re at it I highly suggest you add the binary path for razor into your paths as well:

/opt/razor/bin/razor_daemon.rb status
/opt/razor/bin/razor_daemon.rb start
export PATH=$PATH:/opt/razor/bin

Ok, now we’re getting somewhere!

Now we need to add something called a MicroKernel to the Razor deployment service, so that our deployment VMs actually has something to boot with. This MicroKernel (mk) will give a TON of information back to the razor node, as we’ll see in just a minute. Download and add the MicroKernel as an image to Razor:

wget https://github.com/downloads/puppetlabs/Razor/rz_mk_dev-image.0.8.8.0.iso
razor image add mk ./rz_mk_dev-image.0.8.8.0.iso

Now reboot your deployment VM and you should see that it boots up correctly with an mk image:

If this doesn’t happen you might need to edit your tftp config file (you’ll find it here: /var/lib/tftpboot/pxelinux.cfg/default), like below. Then restart the tftp server (using the command “service tftpd-hpa restart”).

label razor-boot
  menu label Automatic Razor Node Boot
  kernel ipxe.lkrn
  append initrd=razor.ipxe

After a few seconds it will stop similar to this, with VMware vmxnet being the last thing on the screen:

Now the node is up and has network connectivity. Time to do some magic! Run the following to verify that you have gotten a node connected to Razor:

root@puppet:~# razor node
Discovered Nodes
         UUID           Last Checkin  Status                           Tags
2lrdkDEZNwDWm7h41oCmlk  7 sec         A       [IntelCorporation,memsize_1GiB,cpus_2,vmware_vm,nics_1]

You see that our node, with a specific UUID, has something called Tags on it, we’ll use those when we create our Policy for installation. The Tags that we’ll be using is that it has 1GB RAM (memsize_1GiB), 2 CPUs (cpus_2) and is a VMware VM (vmware_vm). Your node’s Tags may vary depending on how you created it.

Now, download the Ubuntu installation ISO (either by downloading it again to the server or copying it using something like FileZilla) and add it as an image to Razor:

root@puppet:~# razor image add os ubuntu-12.04-server-amd64.iso ubuntu_precise 12.04
Attempting to add, please wait...

New image added successfully

Added Image:
 UUID =>  GtGyNOLqaGD1BjFsStJEu
 Type =>  OS Install
 ISO Filename =>  ubuntu-12.04-server-amd64.iso
 Path =>  /opt/razor/image/os/GtGyNOLqaGD1BjFsStJEu
 Status =>  Valid
 OS Name =>  ubuntu_precise
 OS Version =>  12.04

You see that we added the image an OS image, with ubuntu_precise as the OS Name, and 12.04 as the OS Version. That image also has it’s own UUID.

Now we can create a model for that OS installation, and answer a few questions while we’re at it. There are defaults if you don’t want to change anything:

root@puppet:~# razor model add template=ubuntu_precise label=install_precise image_uuid=GtGyNOLqaGD1BjFsStJEu
--- Building Model (ubuntu_precise):
Please enter node hostname prefix (will append node number) (example: node)
default: node
(QUIT to cancel)
 > node
Please enter root password (> 8 characters) (example: P@ssword!)
default: test1234
(QUIT to cancel)
 > test1234
Model created
 Label =>  install_precise
 Template =>  linux_deploy
 Description =>  Ubuntu Precise Model
 UUID =>  7PPnB2R5Aq2BAbnEWr2PJo
 Image UUID =>  GtGyNOLqaGD1BjFsStJEu

With a model created, we can finish off by creating a proper policy (using the Tags we identified earlier for the VM) for installation of Ubuntu on the VMs that we want it to install on.

razor policy add --template linux_deploy --label precise --model-uuid 7PPnB2R5Aq2BAbnEWr2PJo --tags cpus_2,memsize_1GiB,vmware_vm --enabled true

Policy created
 UUID =>  Yf6unMzUdX68qdzpi9sFU
 Line Number =>  0
 Label =>  precise
 Enabled =>  true
 Template =>  linux_deploy
 Description =>  Policy for deploying a Linux-based operating system.
 Tags =>  [cpus_2, memsize_1GiB, vmware_vm]
 Model Label =>  install_precise
 Broker Target =>  none
 Currently Bound =>  0
 Maximum Bound =>  0
 Bound Counter =>  0

Now go and have a look at your deployment VM, it should automatically bind to this policy within a minute or two, reboot and install Ubuntu on it’s own. HOW COOL IS THAT?!

While it’s installing, let’s have a look at some useful razor commands. First, let’s look at that Policy we created again, and verify that there is actually a node bound to that policy:

root@puppet:~# razor policy Yf6unMzUdX68qdzpi9sFU
 UUID =>  Yf6unMzUdX68qdzpi9sFU
 Line Number =>  0
 Label =>  precise
 Enabled =>  true
 Template =>  linux_deploy
 Description =>  Policy for deploying a Linux-based operating system.
 Tags =>  [cpus_2, memsize_1GiB, vmware_vm]
 Model Label =>  install_precise
 Broker Target =>  none
 Currently Bound =>  1
 Maximum Bound =>  0
 Bound Counter =>  1

Perfect, 1 Target Bound!

Let’s look at the razor node command to see that is shows our node as status Bound as well:

root@puppet:~# razor node
Discovered Nodes
         UUID           Last Checkin  Status                           Tags
2lrdkDEZNwDWm7h41oCmlk  5.5 min       B       [IntelCorporation,memsize_1GiB,cpus_2,vmware_vm,nics_1]
root@puppet:~# razor node 2lrdkDEZNwDWm7h41oCmlk
 UUID =>  2lrdkDEZNwDWm7h41oCmlk
 Last Checkin =>  07-02-12 08:34:24
 Status =>  bound
 Tags =>  [IntelCorporation,memsize_1GiB,cpus_2,vmware_vm,nics_1]
 Hardware IDs =>  [000C29E1EEE7]

Now let’s have a look at the logs and see what they tell us:

root@puppet:~# tail -f /opt/razor/log/razor_daemon.log
GET called
/opt/razor/bin/razor -w policy callback 1S9iFYcTrHMvCrDyhsmQbI preseed end '{}'
GET called
/opt/razor/bin/razor -w policy callback 1S9iFYcTrHMvCrDyhsmQbI postinstall inject '{}'
GET called
/opt/razor/bin/razor -w policy callback 1S9iFYcTrHMvCrDyhsmQbI postinstall set_hostname_ok '{}'
GET called
/opt/razor/bin/razor -w policy callback 1S9iFYcTrHMvCrDyhsmQbI postinstall sources_fix '{}'

Seems like it’s done preseeding all the files, installation is done and now it’s just doing a few postinstall things. After a minute or two you should have these in your logs:

root@puppet:~# tail -f /opt/razor/log/razor_daemon.log
GET called
/opt/razor/bin/razor -w policy callback 1S9iFYcTrHMvCrDyhsmQbI postinstall apt_update_ok '{}'
GET called
/opt/razor/bin/razor -w policy callback 1S9iFYcTrHMvCrDyhsmQbI postinstall apt_upgrade_ok '{}'
GET called
/opt/razor/bin/razor -w policy callback 1S9iFYcTrHMvCrDyhsmQbI postinstall apt_install_fail '{}'
GET called
/opt/razor/bin/razor -w policy callback 1S9iFYcTrHMvCrDyhsmQbI postinstall send_ips  '{}'
GET called
/opt/razor/bin/razor -w policy callback 1S9iFYcTrHMvCrDyhsmQbI postinstall boot '{}'

With that last line, your node is ready to be used. Open up the console window and login using username root and password test1234 (or whatever you set in the step above).

You can now automatically deploy more of those Ubuntu servers, just by making sure they have the same Tags as this one. You are a pretty cool admin IMHO! 🙂

For the next step we’ll look into handling more Tags, and actually pushing stuff out to the server after it’s deployed. Stay tuned!

Advertisements

About Jonas Rosland

Open Source Community Manager at {code} by Dell EMC
This entry was posted in Automation, EMC, Installation, IT Transformation, Puppet, Razor, VMware. Bookmark the permalink.

16 Responses to How to get started with Razor and Puppet – Part 2

  1. DanV says:

    Very interesting!

    I am learning about puppet and using vagrant to do development. However, I will soon need to physically deploy servers for the project and would like to use puppet and whatever tools (razor?) there are for doing so.

    It seems, so far that you are working with VMs. Will you be covering physical deployment as well? I am on the edge of my seat…

    • jonas says:

      Hi Dan!

      The deployment process for a physical server is the same as for a virtual machine, you’ll just have different tags that you can include in your policies. You can for instance create a policy with “cpus_2,memsize_16GiB” for a 2 CPU server with 16GB RAM. Try it out 🙂
      I’ll try to cover as much as possible regarding tags in my next post, but unfortunately the documentation is lacking a bit so I need to do some more testing 🙂
      Hopefully I’ll have it out in a couple of days though, so hang tight!

      • DanV says:

        Thanks Jonas. I will have to reread your article again (probably a few times 😉 to more completely absorb it.

        After reading up on Razor I think I am beginning to get the idea. Namely, that PXE boot protocol is used to get hold of a “machine” and the feed it the rest of the desired configuration. And that this is transparent as far as the machine being hardware or “software”. The machine just needs to be set up to support PXE, right?

        Ahh, I see you have posted part 3. Great! Your article could not have come at a more perfect time for me!

      • jonas says:

        You’re completely right. It’s transparent, so both hardware or software will work the same, just make sure you have the tags correctly set up (see Part 3) so you don’t accidently install stuff where it shouldn’t be 🙂

  2. Pingback: vSphere on Open Compute – Part 2, Make it Hurt!

  3. ranjitcool says:

    Hello, the right command is razor image add -t mk -p rz_mk_dev-image.0.8.8.0.iso
    hehehe

  4. Rusheel Jain says:

    Hi
    During automated OS deployment, we need to create a model for OS installation.
    Is there any way that we can pre – make an answer file and pass it to razor for silent installation?

    Thanks

  5. Michael Lozano says:

    I had to go to https://github.com/puppetlabs/Razor-Microkernel/downloads to find the rz_mk_dev-image, and version 0.8.8.0 is no longer there. Latest is 0.9.1.7.

  6. Justin says:

    Hi again,
    a couple of things. How do we go about setting /opt/razor/bin/razor_daemon.rb status to do it automatically, reboot always stops.
    Also I keep having to add nameserver 8.8.8.8 to resolv every reboot, files list itself as dynamic to and will reset. is there a way to fix this entry.

    • Justin says:

      have done a fudge using rc.local to run the demon and copy resolv file

    • Jonas Rosland says:

      Make sure there are no DHCP-clients running on your server, as those will reconfigure your resolv.conf file at every reboot/restart of the service.
      You can add “/opt/razor/bin/razor_daemon.rb start” to your rc.local file, that should do it.

    • Sage Harvey says:

      Assusming you followed part 1 and created a static entry in /etc/network/interfaces, you can add a line to that same file: dns-nameservers 8.8.8.8

  7. thomas says:

    Excellent post. Saved me a lot of grief. Thanks!

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