Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How do I use hiera to include both common and node specific settings?

I'm a new Open Puppet V4.2 user so please be gentle with me. No prior experience with Puppet.

I'm trying to use Hiera to have some common items applied to all nodes plus some node specific items. Not either-or but rather both. So far I've successfully gotten either-or to work but not both.

I'm using the deric/accounts module from the forge as the basis for my user/group account management. It works well and meets my needs...sorta...now just need to figure out how to get both common and specific settings.

I'm fairly sure there is something in my syntax that I'm missing but so far nothing I've tried has worked. The end goal again is to get the accounts listed in the common.yaml added to all nodes plus the accounts listed in nodes/FQDN.yaml file applied to the FQDN node specifically. (Of course FQDN in my example is replaced with the actual fqdn of my target node, e.g. not the literal "fqdn".)

The below setup works....if I test on a node other than "gfmpuptest2" I get the contents of the common.yaml added; if I test on gfmpuptest2 then I get only the information from the nodes/gfmpuptest2.yaml added. I need both added.

Here's my hiera setup:

# cat hiera.yaml

:backends: - yaml

:yaml: :datadir: /etc/puppetlabs/code/environments/%{::environment}/hieradata

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

# cat /etc/puppetlabs/code/environments/lab/hieradata/common.yaml

accounts::groups: www-data: gid: 33333

cat /etc/puppetlabs/code/environments/lab/hieradata/nodes/fqdn.yaml

accounts::groups: www-data4: gid: 43333

cat /etc/puppetlabs/code/environments/lab/manifests/site.pp

class {'accounts': }

class motd { file { '/etc/motd': ensure => file, owner => 'root', group => 'root', content => 'Hello world! Puppet is awesome.', } }

class linux_default { include accounts include motd }

and finally here's my nodes.pp

]# cat /etc/puppetlabs/code/environments/lab/manifests/nodes.pp node 'gfmpuptest2'{

include linux_default

}

node default { include linux_default

file { '/tmp/hello_world': ensure => present, } }

How do I use hiera to include both common and node specific settings?

I'm a new Open Puppet V4.2 user so please be gentle with me. No prior experience with Puppet.

I'm trying to use Hiera to have some common items applied to all nodes plus some node specific items. Not either-or but rather both. So far I've successfully gotten either-or to work but not both.

I'm using the deric/accounts module from the forge as the basis for my user/group account management. It works well and meets my needs...sorta...now just need to figure out how to get both common and specific settings.

I'm fairly sure there is something in my syntax that I'm missing but so far nothing I've tried has worked. The end goal again is to get the accounts listed in the common.yaml added to all nodes plus the accounts listed in nodes/FQDN.yaml file applied to the FQDN node specifically. (Of course FQDN in my example is replaced with the actual fqdn of my target node, e.g. not the literal "fqdn".)

The below setup works....if I test on a node other than "gfmpuptest2" I get the contents of the common.yaml added; if I test on gfmpuptest2 then I get only the information from the nodes/gfmpuptest2.yaml added. I need both added.

Here's my hiera setup:

# cat hiera.yaml

hiera.yaml --- :backends: - yaml

yaml :yaml: :datadir: /etc/puppetlabs/code/environments/%{::environment}/hieradata

/etc/puppetlabs/code/environments/%{::environment}/hieradata :hierarchy: - "nodes/%{::trusted.certname}" - common

common # cat /etc/puppetlabs/code/environments/lab/hieradata/common.yaml

/etc/puppetlabs/code/environments/lab/hieradata/common.yaml --- accounts::groups: www-data: gid: 33333

33333 # cat /etc/puppetlabs/code/environments/lab/hieradata/nodes/fqdn.yaml

/etc/puppetlabs/code/environments/lab/hieradata/nodes/fqdn.yaml accounts::groups: www-data4: gid: 43333

43333 # cat /etc/puppetlabs/code/environments/lab/manifests/site.pp

/etc/puppetlabs/code/environments/lab/manifests/site.pp class {'accounts': }

} class motd { file { '/etc/motd': ensure => file, owner => 'root', group => 'root', content => 'Hello world! Puppet is awesome.', } }

} class linux_default { include accounts include motd }

}

and finally here's my nodes.pp

]#

# cat /etc/puppetlabs/code/environments/lab/manifests/nodes.pp
node 'gfmpuptest2'{

'gfmpuptest2'{ include linux_default

}

linux_default } node default { include linux_default

linux_default file { '/tmp/hello_world': ensure => present, } }

}