Ask Your Question

Razor, hooks and hostnames

asked 2016-02-19 06:23:38 -0600

asktbt gravatar image


I am currently dealing with the problem that I need to assign hostnames within razor to a node before it is installed. This is supposed to make sure the host gets the right hostname and puppet certificate from the start. I was thinking about a way to provide razor dynamically with a hostname using hooks. The hostname pattern provided by razor seems to be hard to set to individual hostnames.
The idea is as follows:

  1. A node boots up and registers at Razor.
  2. A hook (either "node-booted" or "node-registered" is triggered.
  3. As far as I understand hooks until now I could write a script, run a command, alter the json hash I got from razor and return a new hash with an update hostname.

For this purpose I set up an hiera instance on the razor node and will update the datadir using puppet. Then - using whatever key i want - I could assign a hostname to a specific MAC, serialnumber or anything provided by the razor facts.

The advantage I see is that I can already setup a number of hosts before they are installed or powered on and razor would get the hostnames for the installation on the fly. I try to minimize the number of manual actions in razor and keep it in an environment where people are already are used to (like hiera in puppet).

My Question: Is this the way to go or is there an easier way of achiving the goal of having the hostname defined in razor before a node actually shows up?

edit retag flag offensive close merge delete


Hello, I am trying to do something similar to your idea but with a much more deeper integration. I would like to receive kickstart template variables from hiera, and also a way to store node metadata with hiera. May i know, how did you accomplish to query hiera variables from razor node?

worldian gravatar imageworldian ( 2016-10-03 09:45:18 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2016-02-21 22:02:36 -0600

smcclellan gravatar image


You have the right idea for the approach. Take a look at the hostname hook, which is supplied in FOSS Razor 1.0.1 or the Razor supplied in PE 2015.3.x (also available on GitHub here). That hook uses the method you are describing, but rather than using a hiera backend, it increments in code.

The piece which figures out which hostname to use can be implemented in any way.

So, this is definitely an option. Another perhaps more manual option is using a combination of the register-node command and the update-node-metadata command. The register-node command can add the node into the system (based on hardware data which will be used to match the node when it arrives in the system later via the microkernel). Once in the system, the update-node-metadata command can allow that node to use metadata you supply, which in this case would be the "hostname" key.

Either way should achieve what you want, it just depends how you want to maintain the list (hiera for the former, hook, approach, and single usage for the latter approach). I think hooks are a bit more elegant in this case.

Hope that helps!


edit flag offensive delete link more


As a minor addition, the linked hostname hook runs at node-bound-to-policy because that particular implementation uses the policy name to determine the proper hostname. In your example, it sounds like you don't require that, so node-registered would be fine.

smcclellan gravatar imagesmcclellan ( 2016-02-21 22:11:42 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools



Asked: 2016-02-19 06:23:38 -0600

Seen: 459 times

Last updated: Feb 21 '16