Satellite 6 and hiera call within puppet module
Hi all,
I am looking for a little clarification on the hiera calls. I am running Sat6 server v. 6.0.4 . I'm having simple custom made notify_me module imported into SAT6 with one single hiera call. Hiera is configured correctly on the server and by running test hiera call from command line I'm getting correct value.
[root@rhns6]# hiera msg fqdn=node1.local
Test string - HIERA NODE1
I did all settings - Product( with puppet repo) Content view Live cycle and so on .... and finally I have one single module assigned to node1 without any smart parameters or variables.
But when I run puppet agent on node1 I am still gettinng the default value from hiera call.
class notify_me
{
$msg=hiera("msg"',"Default from class file")
notify {"TEST CLASS : $msg":}
}
node1.local:
...
info: Applying configuration version '1416339193'
Notice: TEST CLASS : Default from class file
So my question is : Is it supported scenario ? Can I use hiera calls in puppet modules with SAT6 working as a ENC ? Am I missing something important ?
Thanks,
Jan
Responses
Hi Jan
What you are trying to do is supported by Satellite 6. If it is not working for you, I would recommend for you to check out the following 2 points:
-
When running hiera locally as you do with the "hiera msg fqdn=node1.local" call, hiera is using the /etc/hiera.yaml to figure out where your hiera hierarchy is and where the hiera data ist stored. Puppet by default uses /etc/puppet/hiera.yaml (well $confdir/hiera.yaml to be exact). So the first thing you might want to check is if you your /etc/hiera.yaml and /etc/puppet/hiera.yaml (this file does not exist by default) are the same. Alternatively you could set a different value for hiera_config (https://docs.puppetlabs.com/references/latest/configuration.html#hieraconfig) in your /etc/puppet/puppet.conf. It might als be worthwhile to check out https://docs.puppetlabs.com/hiera/1/configuring.html#from-puppet for more details.
-
Another thing I have regularly run into is the fact that the puppet master service needs to be restarted for the hiera.yaml to take effect. As Satellite 6 uses Passenger this means restarting httpd.
- in RHEL6:
service httpd restart
- in RHEL7
systemctl restart httpd.service
One more thing which is not necessarily related to your issue but might be worthwhile is to check out automatic parameter lookup (https://docs.puppetlabs.com/hiera/1/puppet.html#automatic-parameter-lookup). Basically you could write your above puppet module as:
class notify_me (
$msg = "Default from class file",
) {
notify { "TEST CLASS : $msg": }
}
Hope this helps. Best regards,
David
This is a pretty old post and I'm sure you've got everything worked out quite well by now. I'm just getting into a similar scenario where I want to use Hiera data with Satellite. I found out quickly that it is important where you place your Hiera files because SELinux will prevent Puppet access to them if they are deployed to the wrong place.
Initially I deployed them to the default Hiera location (/var/lib/hiera) but my clients were unable to get parameter values when they were there. Eventually, I created a /etc/puppet/hieradata directory on my Satellite server based on a one or two forum posts that I was able to find.
I'd be interested if Red Hat provides and 'official' direction on how to use Hiera alongside of Satellite.
Also, I just wanted to point out another thing I learned while doing this which is that the Puppet automatic parameter lookup does not perform any merging; it only uses the topmost Hiera configuration that you have. If you are like me and designed your data to be merged, you will be out of luck. However, you can disable automatic lookups by setting puppet.conf/[master]/data_binding_terminus = none and then performing explicit Hiera lookups (e.g. hiera_array, hiera_hash) to perform the required merging.
Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.
