Ask Your Question
0

Confused how to implement sub role / sub class with hiera_include

asked 2016-09-09 18:55:16 -0500

Ivan Arjune gravatar image

updated 2016-10-05 20:55:11 -0500

I set up roles and profiles with hiera.

Nodes are classifing is done in hiera with hiera_include and a custom role fact which assigns the role

If i have a host with facter set to role=mysql and subrole = slave, how do I get the role assigned to role.

Custom facts

/opt/puppetlabs/facter/facts.d/role.yaml
role: mysql

/opt/puppetlabs/facter/facts.d/subrole.yaml
subrole: slave

hiera.yaml

:hierarchy:
  - "nodes/%{::trusted.certname}"
  - "roles/%{::role}"
  - common

site.pp

hiera_include('classes')

hieradata/roles/mysql.yaml

---
classes:
  - profile::mysql
edit retag flag offensive close merge delete

Comments

Are subroles implemented as a conditional statement within the profile manifest?

Ivan Arjune gravatar imageIvan Arjune ( 2016-09-21 14:23:07 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2016-10-06 08:00:33 -0500

lupin gravatar image

updated 2016-10-06 08:01:46 -0500

You add additional layer on your hierarchy.

:hierarchy:
  - "nodes/%{::trusted.certname}"
  - "roles/%{::role}"
  - "subroles/%{::subrole}"
  - common

hieradata/subroles/slave.yaml

---
classes:
    - <whatever_class>
edit flag offensive delete link more

Your Answer

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

Add Answer

Question Tools

1 follower

Stats

Asked: 2016-09-09 18:55:16 -0500

Seen: 86 times

Last updated: Oct 06 '16