I have decided to switch from a single default nodes.pp to a Hiera back-end to manage nodes in Puppet and assign modules to nodes.
We use hostnames as such:
nyc-apache-prod-01
was-mysql-tst-01
This is our hiera.yaml and hierdata-directory structure:
# cat hiera.yaml
:backends:
- yaml
:hierarchy:
- environment/tst/%{::hostname}
- environment/tst
- %{::osfamily}
- common
:logger: console
:yaml:
:datadir: '/etc/puppet/hieradata'
# find hieradata
hieradata
hieradata/RedHat.yaml
hieradata/OracleRAC.yaml
hieradata/common.yaml
hieradata/environment
hieradata/environment/dev
hieradata/environment/tst.yaml
hieradata/environment/acc
hieradata/environment/dev.yaml
hieradata/environment/acc.yaml
hieradata/environment/tst
hieradata/environment/tst/nyc-ks-tst-02.yaml
hieradata/environment/tst/nyc-ks-tst-01.yaml
hieradata/environment/prd
hieradata/environment/prd.yaml
The problem is that environments need to be set as environment=tst in the /etc/puppet/puppet.conf on each individual node. I could write a module to do this based on the hostname of the server, but I am not sure this is the best way to organize servers in seperate environments.
- What is the best way to be able to have different Puppet modules for different servers?
- And what is the best way to add specific modulesto a group of servers?
- e.g. I have 10 Apache webservers... I would like to have all these apache-nodes, no matter if they are tst/acc/dev/prd to have the apache modules.
The thing I want to avoid is to add a list of classes in the list of classes for each individual server. This was the reason we were moving from the single node.pp to a Hiera back-end in the first place.