As described in our quick review of Hiera vs Foreman, all our Puppet modules are designed for usage with Foreman. You can deploy them in 2 ways:
- native Puppet deployment (including Hiera)
- through Foreman.
Native Puppet Deployment
Declaring a puppet class natively can be done in various ways. Most commonly, you would specify a node and the declared classes or modules through site.pp or any other .pp file in the top level manifests folder, like this:
node 'example.example.net' {
include ntp
include my_fw::https
firewall { '69 udp port 69':
proto => 'udp',
dport => '69',
action => 'accept',
}
}
The first line describes the node which gets a class or module declared. This can be a single node, groups or even a regex-based selection. The example above describes a few declarations:
- a module ntp
- a class my_fw::https
- a specific puppet resource type ( here based from the puppetlabs firewall module)
Deploying puppet classes or modules through Foreman requires to import classes and modules first from the Puppet master. Whenever you have a change in your environments ( i.e. after adding or updating a Puppet class or module, you should re-import classes to make sure the Foreman knows about all required parameters.
Once available to Foreman, you declare classes to either hosts or host groups:
When you include a class on a host group, all hosts in the group are impacted through class inheritance.
In order for Foreman to find parameters to work with, the parameters must be located in the class signature:
class example (
package = example.rpm
) {
other_package = another.rpm
package { $package
ensure => present,
}
}
The parameter "package" is included in the class signature ( ) , the "other_package" parameter is not. Foreman will only pick up the first one.
NB: All confdroid puppet modules follow the same layout, as in parameters are always listed in params.pp. The params.pp will then include all required classes. Unless specified otherwise, you always will have to include only params.pp !When you include modules from different authors, this may be different!
If a ConfDroid Puppet module is requiring other classes, it will do so within the module automatically. However. typically the referred module also has parameters set. If those need to be overridden on Foreman level, you will have to manually also include the params.pp for the other module. Otherwise any values set as default in the required params.pp will be applied.
Once a class is included on a host or host group, the next puppet run will execute them. If you change a parameter override on Foreman, the change will be implemented at the next Puppet run.