Chef, Razor, OpenStack – Part 2

In the last post we talked about what it is we are building as well as built the Chef Server that will service the remainder of the environment. As before, this work is being done in conjunction with the upcoming updated release of the OpenStack Cookbook with Kevin Jackson. In this part we will cover building the Razor node that will handle provisioning our “physical” nodes.

But wait, there’s more…

Installing Razor

Razor is a bare metal provisioning system that consists of a few components. Images, Policies, Micro Kernel and the Broker (as well as some others). When a node PXE boots, it boots into the Razor Micro Kernel environment which in turn runs PuppetLabs Facter and reports back /lots/ of details about the physical node. From there, you can use the Razor CLI or Razor API to query inventory details about a machine or set of machines and provision an OS to them. An additional feature is the “Broker” which is what allows for a hand-off to a DevOps framework. In this section we will cover using the Razor cookbooks to install Razor onto the node.

Getting Started

To begin, we start with a 1 vCPU, 1GB Ram, 20GB disk Ubuntu 12.04 installation, as well as the Chef Server we built in Part 1. From there we do the following:

On the Chef Server

Before we actually touch the Razor node, we need to define how we want it configured. To do this we use Chef and create a json representation of the node. On the Chef server, do the following:

sudo cat > ~/.chef/razor.json <<EOF
“name”: “”,
“chef_environment”: “_default”,
“normal”: {
“dhcp”: {
“parameters”: {
“next-server”: “”
“networks”: [ “172-16-0-0_24” ],
“networks_bag”: “dhcp_networks”
“razor”: {
“bind_address”: “”,
“images”: {
“razor-mk”: {
“type”: “mk”,
“url”: “”,
“action”: “add”
“precise64”: {
“url”: “”,
“version”: “12.04”,
“action”: “add”
“tags”: []
“run_list”: [

knife node from file ~/.chef/razor.json

How it worked

The first command above created a json file that defines how we want Chef to configure our Razor node. In the json file, there are two sections the define our specific services, “dhcp” and “razor” respectively. Finally, after specifying the configuration, we add the razor and dhcp recipes to our node and import the node to the Chef Server. Our next step then, is to log into our Razor node.

On the Razor node:

mkdir -p /etc/chef
scp user@host:/location/of/chef-validator.pem /etc/chef/validation.pem

sudo echo “” >> /etc/hosts

# Install chef client
curl -L | sudo bash

# Make client.rb
sudo cat > /etc/chef/client.rb <<EOF
log_level       :info
log_location    STDOUT
chef_server_url ‘’
validation_client_name  ‘chef-validator’

sudo chef-client

How this worked:

First we copied over our chef server validator.pem file. Next we created a hosts file entry to let the server know where to find the chef server. Following that we installed and configured the chef-client. As a last step we ran chef-client to register our node with the Chef-Server. Which in turn will have generated A LOT of output.

Configuring Razor

Now that DHCP and Razor have been installed there is still some work that needs to be done. Specifically, we need to:

  • Create a Broker
  • Create a Model
  • Create a Policy

So without further adieu, log into the Razor server as root and execute the following commands:

# razor broker add -p chef -n ChefServer -d “Cookbook Chef Broker”
— Building Broker (chef):

Please enter the URL for the Chef server. (example:
(QUIT to cancel)
Please enter the Chef version (used in gem install). (example: 10.16.2)
(QUIT to cancel)
> 10.16.2
Please enter a paste of the contents of the validation.pem file, followed by a blank line. (example: —–BEGIN RSA PRIVATE KEY—–nMIIEpAIBAA…)
(QUIT to cancel)


Please enter the validation client name. (example: myorg-validator)
default: chef-validator
(QUIT to cancel)
Please enter the Chef environment in which the chef-client will run. (example: production)
default: _default
(QUIT to cancel)
Please enter the Omnibus installer script URL. (example:
(QUIT to cancel)
Please enter an alternate path to the chef-client binary. (example: /usr/local/bin/chef-client)
default: chef-client
(QUIT to cancel)
Please enter an optional run_list of common base roles. (example: role[base],role[another])
(SKIP to skip, QUIT to cancel)
Please enter an optional run_list of common base roles. (example: role[base],role[another])
(SKIP to skip, QUIT to cancel)

Name =>  ChefServer
Description =>  Cookbook
Plugin =>  chef
UUID =>  3hrANDuaTiH241tsWV8Olq
Chef Server URL =>
Chef Version =>  10.16.2
Validation Key MD5 Hash =>  1d977df28d971df5a382c51f637a1b6d
Validation Client Name =>  chef-validator
Bootstrap Environment =>  _default
Install Sh Url =>
Chef Client Path =>  chef-client
Base Run List =>

# razor model add -t ubuntu_precise -l BaseInstall -I <image uuid from razor image command>

— Building Model (ubuntu_precise):

Please enter node hostname prefix (will append node number) (example: node)
default: node
(QUIT to cancel)
Please enter local domain name (will be used in /etc/hosts file) (example:
default: localdomain
(QUIT to cancel)
Please enter root password (> 8 characters) (example: P@ssword!)
default: test1234
(QUIT to cancel)
Model created
Label =>  OpenStack_Base
Template =>  linux_deploy
Description =>  Ubuntu Precise Model
UUID =>  5Dr66oSci0plnAMGOy1l94
Image UUID =>  5Kt3MQyMOFQdIvRRL5mXiA

# razor policy add -p linux_deploy -l OpenStack_Base -m <modelUUID> -b <brokerUUID> -t nics_1,memsize_1GiB -e true
Policy created
UUID =>  2EWCjgZx45R5N5yjrPOMFy
Line Number =>  0
Label =>  OpenStack_Base
Enabled =>  true
Template =>  linux_deploy
Description =>  Policy for deploying a Linux-based operating system.
Tags =>  [nics_1, memsize_1GiB]
Model Label =>  OpenStack_Base
Broker Target =>  ChefServer
Currently Bound =>  0
Maximum Bound =>  0
Bound Counter =>  0

How this worked:

The first command “razor broker add” specified what type of broker and how we wanted to refer to the broker in the system. This is useful when you have multiple environments that you may be managing. We then supplied values interactively to provide configuration for our broker.

Next, the “razor model add” command lets us associate various bits of data that will be used during the installation of our node. Specifically, which image we will be using, the default passwords for said image, and then some.

Finally, the “razor policy add” is what makes it all real. We tie together the build info, details about the node, as well as other variables to tell razor what to do with nodes it finds that match these criteria. In this case, a node with 1 NIC and 1GB ram will match our policy, have Ubuntu 12.04 installed with the chef client configure to talk to the chef server in our environment.


This one was another ginormous post, for that I’m sorry. The TLDR of what we did: In part 1 we installed and configured Chef Server. In this part we used chef server to install and configure both DHCP as well as Razor. Additionally we configured a Razor broker, Razor model, and Razor policy to catch any node that boots up and apply our default Ubuntu install and connect it with Chef. In the last part of this series, we’ll boot a few nodes and show you how to install OpenStack onto them after Razor has handed them off.

3 thoughts on “Chef, Razor, OpenStack – Part 2

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.