Razor, hooks and hostnames
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:
- A node boots up and registers at Razor.
- A hook (either "node-booted" or "node-registered" is triggered.
- 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?