Hi,
we are about to start deploying a larger set of client hosts and want to use foreman/puppet to provision them. Some hosts needs different classes in puppet so the question is how to distinguish them.
We thought about to give some hint in puppet.conf eg some variable that is send to foreman and then depending on this variable assign different classes to hosts.
Sadly i could not find anything right now to get this right. Is this even possible or are there other ways? Thanks alot.
Rene
There are a lot of different design patterns for this, some that come to mind:
- Puppet roles/profiles design pattern
- Use host groups (classes assigned to host groups automatically apply to hosts within them)
- You can use smart class matchers on ANY foreman parameter, so if you had the same class but wanted to dynamically assign puppet parameter values based on anything, such as content view, lifecycle environment, owner, etc you could go this route. Sometimes I do things based on lifecycle, or a custom parameter we have for the hosts security zone to make sure settings are enforced regardless of how the host or host group is configured.
- Hiera (I don’t know much about this)
I am not aware of a way to dynamically assign classes natively in Foreman, but the host group pattern is generally pretty easy to implement.
Thanks for your answer, the host groups way seems the way to go.
But one more question. Now when i want to add a new host to foreman and run puppet agent, how do i tell Foreman he should put this host in the specific hostgroup automatically? So i just want to install the host and run puppet agent but dont want to touch the foreman config.
Thanks
Rene
Maybe its possible to add a trigger script? So when a host is added foreman triggers a custom script and then i can add this host to a specific hostgroup automatically?
Another possibility is to pre-create the foreman object via the API. If you “create” a foreman host in foreman with the same FQDN (and configure hostgroups, params, etc. automatically) the first check-in uses the existing object (it’s based on certname IIRC). And any ENC params, classes, etc, are just “used”
There is a bootstrap script https://github.com/Katello/katello-client-bootstrap that you can use if you want to pre-create hosts in a given host group. If you are using foreman/katello for provisioning, you select the host group while building a new system.