Hiera role inheritance

asked 2017-05-13 13:30:28 -0500

I've got three roles defined in my control repo: desktop_common, desktop_office, and desktop_developer. I'm using hiera to set a variable systemd_default_target, which is multi-user in my common.yaml, but I'd like it to be graphical for all the roles above. (There are other roles which run headless, so it makes sense for the default to be multi-user.)

if I set a parameter in Foreman (my ENC) on each host group, called role, to specify which role to apply, and include roles::desktop_common in both of the others, most things are working fine, but it looks as though I now have to have the following in my hiera data:

common.yaml contains systemd_default_target: multi-user

roles/desktop_common.yaml contains systemd_default_target: graphical

roles/desktop_developer.yaml contains systemd_default_target: graphical

roles/desktop_office.yaml contains systemd_default_target: graphical

Is there a way to reduce this duplication, either by using some feature of hiera or by designing my roles better?

edit retag flag offensive close merge delete


What's your existing hierarchy like?

smarlow gravatar imagesmarlow ( 2017-05-13 13:39:42 -0500 )edit

nodes/%{trusted.certname} roles/%{puppet_role} default

iainhallam gravatar imageiainhallam ( 2017-05-19 04:59:51 -0500 )edit