Ask Your Question

layering hiera

asked 2013-10-07 22:51:31 -0500

gmcgrath815 gravatar image

I've moved most of my node classification into hiera at this point using the classes + hiera_include behavior but now I'm trying to introduce the concept of rolls and seem to be hitting a bit of a wall.

My present hiera.yaml is fairly simple:

    - yaml
    :datadir: "/usr/local/puppet-conf/env/%{::environment}/hieradata"
    - "node/%{::fqdn}"
    - "roles/%{role}"
    - %{role}
    - common

:merge_behavior: deeper

Currently I've got a common.yaml file with a set of mounts (in the case of this plugin directories, nfs mounts and symbolic links) that appears as follows:

  - mounts
  - accounts
## Mount Configs
mounts ...
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2013-10-08 02:30:10 -0500

Ancillas gravatar image

Typically, you'd only assign a role class from hiera, and the role class would be responsible for including the other classes.

Here's a similar example I wrote up that may help you visualize it.

What I would do in your role classes is define a variable called $role.

class role::webserver {
  $role = webserver

And then since you have $role in hiera.yaml already, you can use it in combination with hiera_hash(), which will do a merge instead of picking the first hash it finds.

So, when you call hiera_hash('mounts::nfs') from your class added by the role ... (more)

edit flag offensive delete link more


This seems like it's coupling the data with the task at hand. For instance many of my servers have cron jobs, but not all of them have the same ...(more)

gmcgrath815 gravatar imagegmcgrath815 ( 2013-10-08 08:43:08 -0500 )edit

Your problem is that in hiera.yaml, you have `roles/%{role}`, but role isn't something that is defined unless you've defined it. A role wrapper class is used ...(more)

Ancillas gravatar imageAncillas ( 2013-10-08 14:08:30 -0500 )edit

The above suggestion seems tie that data to fqdn and common, I'm asking if anybody has an idea how to make role provide additional data and nothing else. I ...(more)

gmcgrath815 gravatar imagegmcgrath815 ( 2013-10-08 15:41:07 -0500 )edit

Somewhere you need to assign a role to a node. Your example does this via hiera by hostname, "...include them in the relevant hosts if possible...".. You're using an ...(more)

Ancillas gravatar imageAncillas ( 2013-10-08 20:52:19 -0500 )edit

The accepted convention is wrapper classes. Perhaps I don't fully understand your use case, but from my chair, it solves all of your problems, while still maintaining your hiera_include ...(more)

Ancillas gravatar imageAncillas ( 2013-10-08 20:54:25 -0500 )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



Asked: 2013-10-07 22:51:31 -0500

Seen: 499 times

Last updated: Oct 08 '13