--
You received this message because you are subscribed to the Google Groups "puppet-razor" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-razor...@googlegroups.com.
To post to this group, send email to puppet...@googlegroups.com.
Visit this group at https://groups.google.com/group/puppet-razor.
For more options, visit https://groups.google.com/d/optout.
I did a dig into the hook function but still struggling to have something that works.
Lets explain. I'd like to know which node was calling the hook and extract some facts about it to allow me to provide the right hostname. Facts are Mac/uuid/serial number.
I Wonder how to have them when the hook is called.
By the way I tried to do this kind of query on the api
/api/collections/nodes?uuid=xxxxxxx to have the node name but got an empty result.
Many thanks for your help.
Nicolas
Hi Nicholas,
How this would work is that when the node boots and contacts Razor, reporting its facts for the first time, the Razor server will run the hook script with filename "node-registered". When that hook script gets triggered, it is passed as input via STDIN the data that you want about the node. An example of a script reading this input is here (this is ruby):
https://github.com/puppetlabs/razor-server/blob/master/hooks/hostname.hook/node-bound-to-policy#L5
"Extracting the facts about the node" would consist of the hook script reading this STDIN, parsing that string (it's sent as JSON), then pulling out the facts you want. The script can calculate what you'd like the hostname to be, and then needs to output (using `echo`, for example) this hostname you want, also in the correct JSON format. The JSON format for output is described by the docs in my past email. The simplest output script to change the "hostname" metadata value on a node would be (this is just bash):
cat <<EOF
{ "node": { "metadata": { "hostname": "some-hostname" } } }
EOF
Hope that helps! If you need more assistance, I'll need to know the language you're using to write the script (and maybe code fragments) to help more effectively.
Scott
--
You received this message because you are subscribed to the Google Groups "puppet-razor" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-razor...@googlegroups.com.
To post to this group, send email to puppet...@googlegroups.com.
Visit this group at https://groups.google.com/group/puppet-razor.
For more options, visit https://groups.google.com/d/optout.