Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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:


This is our hiera.yaml and hierdata-directory structure:

# cat hiera.yaml 
    - yaml

    - environment/tst/%{::hostname}
    - environment/tst
    - %{::osfamily}
    - common

:logger: console

    :datadir: '/etc/puppet/hieradata'

# find hieradata

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.

share|improve this question
Possible duplicate of… – dawud May 31 '13 at 15:48
How do you want to assign the environment? If the hostname standard is consistent, you can just get it from there, or you can configure it per-node. Similarly, do you want the group decisions for modules to be based on the hostname, assigned specifically in the hiera data for that node, or some other method? – Shane Madden Jun 1 '13 at 7:11
up vote 0 down vote accepted

You might want to assign a role to servers, and use that to provide them with packages.

For instance; in /etc/facter/facts.d you put a file that sets a role fact. You could use that as a Hiera hierarchy level to assign modules to the servers then.

Never tried it myself, but I think that could work.. :)

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.