Skip to content

Instantly share code, notes, and snippets.

@nightfly19
Last active December 17, 2015 21:29
Show Gist options
  • Select an option

  • Save nightfly19/5675032 to your computer and use it in GitHub Desktop.

Select an option

Save nightfly19/5675032 to your computer and use it in GitHub Desktop.
The variable names in global.yaml are being expanded when the template is expanded. Not sure where I need to escape something
#global.yaml
'puppet::hiera::backends': - file
- yaml
'puppet::hiera::logger': console
'puppet::hiera::hierarchy': - '%{::environment}/fqdn/%{::fqdn}'
- 'fqdn/%{::fqdn}'
- '%{::environment}'
- global
'puppet::hiera::yaml':
:datadir: /var/lib/hiera
#hiera.pp
class puppet::hiera (
$backends = ['yaml'],
$logger = ['console'],
$hierarchy = ['global'],
$yaml = {':datadir' => '/var/lib/hiera'},
$other = {}
) {
#Puppet configuration
file{'/etc/puppet/hiera.yaml':
ensure => present,
mode => '0660',
owner => 'puppet',
content => template('puppet/hiera.yaml.erb'),
require => Package['puppet'],
notify => $::puppet::to_notify,
}
}
#hiera.yaml.erb
<%
require 'yaml'
data = {:backends => @backends,
:logger => @logger,
:hierarchy => @hierarchy,
:yaml => @yaml}.merge( @other.class == Hash ? @other : {})
-%>
<%= data.to_yaml%>
#evaluates to
---
!ruby/sym hierarchy:
- production/fqdn/rainbowdash.sagenite.net
- fqdn/rainbowdash.sagenite.net
- production
- global
!ruby/sym logger: console
!ruby/sym yaml:
!ruby/sym datadir: /var/lib/hiera
!ruby/sym backends:
- file
- yaml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment