Ask Your Question
0

Configure puppet razor kickstart templates/variables with hiera from puppet master node, during provisioning of that respective node with help of its "mac" factor.

asked 2016-10-03 10:16:47 -0500

worldian gravatar image

Hello,

My ultimate goal is to have puppet master take care of node deployment configuration even before OS gets deployed. That is puppet master configuring kickstart templates/disk partitions of a node with help of facts on puppet razor and hiera with role/profile pattern.

To be more specific. Our environment needs different disk partitions/kickstart passwords/kickstart templates depending on the role/profile/cluster of the node. All this data cannot be received from factor and instead has to come from a CMDB/hiera. We are already used to configuring nodes post OS deployment with the help of role/profile pattern and using hiera to distribute the data across the hierarchy.

I am just trying out puppet razor and its features, thinking it would solve this problem of receiving kicstart data about a node from hiera depending on its mac-address. I would also like to configure hostname depending on the node mac-address which it would receive from hiera.

I could accomplish the above by using puppet and hiera, and manually enter kickstart data on hiera for razor node and configure with puppet - but in this case - I will need me to mention all the kickstart static data of all the nodes as "razor node data on hiera". I do not want to create a huge set of static data for razor node. I would instead want the kickstart template on puppet razor node to be automatically populated whenever that respective node gets deployed through razor.

In short this is the hierarchy that i have..


:backends: - yaml - eyaml :yaml: :datadir: "<>" :eyaml: :datadir: "<>" :pkcs7privatekey: /<> :pkcs7publickey: /<> :hierarchy: - "nodes/%{::trusted.certname}" - "mac/%{::mac}" - "virtual/%{::virtual}" - "role/%{role}" - "cluster/%{cluster}" - "os/%{::operatingsystem}/%{::operatingsystemmajrelease}" - common :merge_behavior: deep :logger: puppet

I would want to specify data as follows:

mac/ef:as:as:sg:as:fg "disk partitiion": "<>"

cluster/test "disk partition":<>

role/test "disk partition":<>

I would then want the respective node during node provisioning to pick up the above data from hiera depending on its facts "::mac", and use the data in kickstart template/pxe templates etc...

That would help me keep all the configuration data for a node at one place(hiera), and not repeat it or use some other tool to do the same with some other database.

Please let me know, if anyone has any ideas on how to accomplish the above.

Thanks,

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2016-10-04 15:39:31 -0500

smcclellan gravatar image

Hi there,

The main tool that Razor has for situations like this is hooks. Hooks are a way for Razor to run arbitrary scripts during certain node events. A hook script can be used to update a node's metadata, which it sounds like is what you need. Hooks can be written in any executable language, and have a generic input/output scheme. So pick any language you're comfortable with.

In your scenario, you could pull in any hiera config into a node's metadata. The trick would be figuring out the right stage to do so. I'd guess that updating whenever a node boots would be fine.

If you're interested in this, I'd recommend starting by looking at the hostname hook here, which could be modified to read hostname data from any source:

https://github.com/puppetlabs/razor-s... https://github.com/puppetlabs/razor-s...

If you want more detail on how hooks work, here's a README:

https://github.com/puppetlabs/razor-s...

Hope that helps, let me know in the comments if you have any other questions.

Scott

edit flag offensive delete link more

Comments

Thank you Scott. I was working on the same. I have almost got a hook script running using hiera-restful api, to pick up hiera data and modify node metadata. I am yet to experiment with hashes, but can node-metadata pick up any values - even hashes?

worldian gravatar imageworldian ( 2016-10-05 17:31:22 -0500 )edit

Node metadata can store any data, but if you want to use it in a tag, keep it scalar (not a hash or an array) for now.

smcclellan gravatar imagesmcclellan ( 2017-02-01 16:28:12 -0500 )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

2 followers

Stats

Asked: 2016-10-03 10:12:05 -0500

Seen: 68 times

Last updated: Oct 04 '16