Puppet/Foreman – Hostgroups and classes

foremanpuppetpuppet-foremanpuppetmaster

I successfully set up foreman and puppet. Now I'm trying to configure host groups which should contain a specific configuration.

My example: Host group "Basic" should get a special MOTD.

I installed a MOTD-module for puppet:

puppet module install puppetlabs-motd

Now I imported the class to foreman – works also fine.

Next step was adding a new host group:

New host group

Okay, fine. Now I'm adding my new motd-class:
Class

Okay, now it would be fine if all hosts belonging to the host group "Basis" would show a MOTD-text "Hello World". If I configure another host group "Test" which is also using the motd-module the text should be "Bye, bye world".

How can I specify parameters for each host group this way?

Best Answer

The motd module you downloaded has a "content" parameter on the motd class that controls what's in the /etc/motd file. This is shown at https://forge.puppetlabs.com/puppetlabs/motd#usage.

By default, Foreman doesn't set the value of any class parameters. Go to Configure > Puppet classes (sorry, you'll have to translate to German), click on the class and go to the Smart class parameters tab.

The known (imported) smart class parameters are listed on the left, click content, tick the Override checkbox and either enter a default value for it or tick the Use Puppet default box if you prefer.

When editing a host or host group with the class assigned, the content parameter will now be listed on the Parameters tab and can be overridden. Click the override button to set a value on the host group and save it. Host overrides take precedence over a host group override.

More information on these overrides is in the Smart Matchers part of the Foreman manual. They can be configured in more detail on the Puppet classes page above.