I'm trying to understand how does Puppet hierarchy works.
My Puppet server's hiera.yaml
looks like so:
[root@puppet puppet]# cat hiera.yaml
:backends:
- yaml
:yaml:
:datadir: '/etc/puppet/hieradata/%{::environment}'
:hierarchy:
- fqdns/%{::fqdn}
- roles/%{::role}
- domains/%{::domain}
- common
There are modules which I want all servers to have so I've put them in the common.yaml
file and there are role-specific modules which are included in each role.yaml
file.
When a server which matches a role in Puppet starts, the modules from the role.yaml
file are loaded first.
My question is:
Once a server is matched with a role... will it stop there? or will it continue in the hierarchy and load the modules under the common.yaml
as well?
If not, How can I make sure that this is how it will behave?
Edit #1:
Here's an example of one of the role.yaml
files:
[root@puppet roles]# cat dataorigin.yaml
classes:
- workspace
jdk_enable: true
jdk_ver: 1.6.0_41
component_ver: 1-1-5-17
tomcat_enable: true
debug_mode: true
fstab_params:
mount1:
mnt_src: "isilonnj01.eyedcny.local:/ifs/Peer39/do_share"
mnt_dest: "/doshare"
mnt_opts: "tcp,hard,intr,noatime"
mnt_dest_parent: ""
And the server's site.pp
looks like so:
hiera_include("classes", [])
Package { allow_virtual => false, }
node default {
include stdlib
}
Edit #2: Here's an example of a motd module:
include stdlib
class motd {
file { "/etc/custom_motd.sh":
path => '/etc/custom_motd.sh',
ensure => present,
owner => "root",
group => "root",
mode => "775",
content => template('motd/custom_motd.sh.erb'),
#require => Class['nagios_client'],
}
file_line { 'enable motd':
ensure => present,
line => '/etc/custom_motd.sh',
path => '/etc/profile',
require => File['/etc/custom_motd.sh']
}
}
The motd module
is configured in the common.yaml
file, and in the role.yaml
file there's a module called workspace.
How can I tell Puppet to load the motd module
from the common.yaml
file?
How can I tell Puppet to lost the motd module from the common.yaml file?
Can you rephrase that please? You want Hiera to yield only the first match, not all? You want to selectively ignore one module? I'm not sure.