Skip to content

Instantly share code, notes, and snippets.

@kreczko
Last active February 12, 2016 16:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kreczko/3cfd094dd9e50b29f82f to your computer and use it in GitHub Desktop.
Save kreczko/3cfd094dd9e50b29f82f to your computer and use it in GitHub Desktop.
hiera with external facts
---
message: "This is our common yaml file"
classes:
- site
- 'profile::base'
---
:backends:
- yaml
:hierarchy:
- "nodes/%{::fqdn}"
- "cluster/%{::node_info.cluster}"
- "groups/%{::node_info.group}"
- "roles/%{::node_info.role}"
- common
:yaml:
# datadir is empty here, so hiera uses its defaults:
# - /etc/puppetlabs/code/environments/%{environment}/hieradata on *nix
# - %CommonAppData%\PuppetLabs\code\environments\%{environment}\hieradata on Windows
# When specifying a datadir, make sure the directory exists.
:datadir: /etc/puppetlabs/code/environments/%{environment}/hieradata
class site (
$node_info = undef,) {
notify {"${::node_info['cluster']}": }
if $node_info {
file { [
'/etc/puppetlabs/facter/',
'/etc/puppetlabs/facter/facts.d']: ensure => directory, }
file { '/etc/puppetlabs/facter/facts.d/node_info.yaml':
content => template("${module_name}/node_info.erb"),
owner => root,
group => root,
mode => '0644',
}
}
notify { hiera('message', 'none'): }
}
---
site::node_info:
cluster: dice
group: service
role: puppetserver
---
site::node_info:
cluster: dice
group: service
role: puppetserver
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment