Ask Your Question
0

How to group nodes using hiera ?

asked 2013-07-02 05:03:56 -0600

Przemek gravatar image

Hi,

Currently our hiera.yaml file is the following:

---
:backends:
  - yaml
:hierarchy:
  - nodes/%{fqdn}
  - virtual/%{virtual}
  - os/%{operatingsystem}/%{operatingsystemmajrelease}
  - common
:yaml:
  :datadir: /etc/puppet/environments/%{environment}/hieradata

I would like to group hosts and apply some puppet configs to group of hosts - sth like that:

:hierarchy:
  - nodes/%{fqdn}
  - nodes/%{group}  <------ !!!
  - virtual/%{virtual}
  - os/%{operatingsystem}/%{operatingsystemmajrelease}
  - common

I wanted to classify nodes based on their groups but all keep in hiera based files. Something like this (the nodes hostnames are so different that I cannot use puppet regexps) :

---
group1:
  - node23
  - node2
  - node123

group2:
  - node5
  - node12
  - node22

etc

Is it somehow possible ... (more)

edit retag flag offensive close merge delete

3 Answers

Sort by ยป oldest newest most voted
1

answered 2013-07-02 12:57:54 -0600

Ancillas gravatar image

I might do this using an external fact on the servers themselves. You'd drop a file on each server that self-classifies the node. In this case, that external fact would supply %{group} for hiera lookups.

I've also seen Puppet environments used this way. Each group maps to a single Puppet environment. For the first puppet run, you specify the correct environment, and the node gets the config for that environment. If goes a bit against the grain because you'll end up with multiple production environments, multiple test environments, and so on and so forth, but you can ... (more)

edit flag offensive delete link more

Comments

We use environments (up to 8). But they are not good for fine grained granularity especially when you have over 100 nodes in each env (you would need to create ...(more)

Przemek gravatar imagePrzemek ( 2013-07-03 05:00:53 -0600 )edit

You would need 1 file on each node that defines that node's group. You can't avoid that work. Somewhere, there needs to be one something that ties together ...(more)

Ancillas gravatar imageAncillas ( 2013-07-03 11:16:56 -0600 )edit

I would like to request for enhancement for this kind of problem (for me hiera seems natural way to do that). Where I can do that ?

Przemek gravatar imagePrzemek ( 2013-07-15 09:45:41 -0600 )edit

I am wondering if there is a better solution to the above problem, now that is year have passed since the question was asked, in another configuration management tool it is isolated by a yaml inventory where it is easy to configure hierarchy of groups, where each group could include nodes in a group, and easily tie this to data specific either to the nodes or groups. also the group could classify data within the same file if needed, or could specify that it is a container for other child groups. what would be the best way to solve this problem these days in puppet ECO system, hopefully using Centralized Hiera?

Walid Shaari gravatar imageWalid Shaari ( 2014-08-21 15:02:36 -0600 )edit
1

answered 2014-09-11 20:14:31 -0600

A proof of concept: https://gist.github.com/joshbeard/73c...

This is a bit obscure, but it does what you're asking (I think).

edit flag offensive delete link more

Comments

I commented on github

Walid Shaari gravatar imageWalid Shaari ( 2014-09-12 15:32:21 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 2013-07-02 05:03:56 -0600

Seen: 2,460 times

Last updated: Sep 11 '14