Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question
    
Possible duplicate of serverfault.com/questions/509075/… –  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

1 Answer 1

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

 
discard

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.