-
Notifications
You must be signed in to change notification settings - Fork 163
Getting started
This page explains the most important commands for getting started. We assume that you have a Razor server up and running (if not, go to Installation)
The command line client is a small utility that makes interacting with the Razor server's REST API more convenient. As the server and the client only communicate over HTTP, there is no need to run the client on the same machine as the server, and running the client locally is generally preferrable.
The client requires that a Ruby is installed that is compatible with Ruby 1.9.3; compared to the Razor server, there is no need to run the client under jRuby, and using a Ruby interpreter with a faster startup time, like MRI Ruby is usually more convenient.
The client is distributed as a gem and can be installed with
gem install razor-client
and can be pointed at the Razor server either by speciying the server's API
URL with the --url
option, or by setting the RAZOR_API
environment
variable. The following two commands have the same effect and list all
nodes on the server http://razor:8080/api
:
razor --url http://razor:8080/api nodes
RAZOR_API=http://razor:8080/api razor nodes
To use Razor, you will need to create a few basic objects on the server. Most importantly, you'll want to load at least one repo into the server and declare a broker:
razor create-repo --name=centos-6.4 --iso-url http://some.where/centos.iso
All the objects you use with Razor are identified by a name, which has to
be unique (i.e., there can only be one repo called 'sles-11') The repo
contains the actual bits that are used when installing a node; the
instructions for installation are contained in recipes, and Razor comes
with a few predefined recipes to get you started. They can be found in the
recipes/
directory in the razor-server
repo, and can all be used by
simply mentioning their name in a policy as described below, including the
vmware_esxi
installer; the one exception to this is the Windows
installer, which requires additional preparation.
Besides repos and recipes, you'll also need a broker; brokers are
responsible for handing a node off to a config management system, usually
Puppet. We'll set up a simple
noop
broker, that does nothing:
razor create-broker --name=noop --broker-type=noop
With that set up, we can create a policy. Policies tie all the other bits
and pieces in Razor together, and are what gets ultimately applied to a
host. Since a command line to create a policy would be quite a mouthful, we
store the policy in a JSON file, say policy.json
:
{
"name": "centos-for-small",
"repo": { "name": "centos-6.4" },
"recipe": { "name": "centos" },
"broker": { "name": "noop" },
"enabled": true,
"hostname": "host${id}.example.com",
"root_password": "secret",
"max_count": "20",
"rule_number": "100",
"tags": [{ "name": "small", "rule": ["<=", ["num", ["fact", "processorcount"]], 2]}]
}
and create it on the server:
razor create-policy --json policy.json
With that, the first 20 nodes with no more than two processors that boot
will get the centos-for-small
policy applied to them.
Running razor nodes
will produce a list of all the nodes that the Razor
server knows about, and looks something like this:
Id: "http://razor:8080/api/collections/nodes/5254000d97f0"
Name: "5254000d97f0"
Type: "/razor/v1/collections/nodes/member"
... more nodes ...
The name of the node is simply the MAC address of its interface (or those
MAC addresses glommed together if the node has more than one interface). It
can be used to get more information about the node via razor nodes 5254000d97f0
Id: "http://razor:8080/api/collections/nodes/5254000d97f0"
Name: "5254000d97f0"
Type: "/razor/v1/collections/nodes/member"
Hw_id: "5254000d97f0"
Dhcp_mac: "01-52-54-00-0d-97-f0"
Policy: ...
Log: ...
Facts:
Id: "root"
Architecture: "x86_64"
Kernel: "Linux"
Domain: "localhost"
Macaddress: "52:54:00:0d:97:f0"
...
and razor nodes 5254000d97f0 log
displays the log of that node:
Event: "boot"
Recipe: "microkernel"
Template: "boot"
Repo: "microkernel"
Timestamp: 1377104696
Severity: "info"
Event: "bind"
Policy: "fedora-for-any"
Timestamp: 1377105312
Severity: "info"
Action: "reboot"
Policy: "fedora-for-any"
Timestamp: 1377105312
Severity: "info"
Event: "boot"
Recipe: "redhat"
Template: "boot_install"
Repo: "fedora-19"
Timestamp: 1377105319
Severity: "info"
For any of the collections that Razor supports, you can use razor COLLECTION
to get a list of that collection, and razor COLLECTION NAME
to get the details of an object in that collection. Running razor -h
will
list all the collections the server knows about.
As an example, razor tags
lists all tags, and razor tags test
shows the
details of the tag with name test
.