I tried both epp and erb templates.
This is the manifest file:
class site::profiles::ntp {
$ntp = hiera_hash('ntp')
case $::operatingsystem {
'freebsd': {
file { "/etc/ntp.conf":
ensure => file,
recurse => true,
purge => true,
force => true,
owner => "root",
group => 0,
mode => "0644",
content => template('site/ntp/ntp.conf.epp'),
#content => template('site/ntp/ntp.conf.erb'),
}
service { 'ntpd':
ensure => 'running',
enable => true,
}
service { 'ntpdate':
enable => true,
}
}
default: {
class { 'ntp':
servers => $ntp['servers'],
}
}
}
}
The template:
templates/ntp/ntp.conf.epp
<% @ntp[’servers’].each { |server| -%>
server: <%= server %>
<% } -%>
And this is the hiera (as of now there is only one ntp server but there'll be more in the future):
ntp:
servers:
- 169.254.169.123
Martin with the latest change I'm getting:
Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Evaluation Error: Error while evaluating a Resource Statement, Evaluation Error: Error while evaluating a Function Call, Failed to parse template site/ntp/ntp.conf.epp:
Filepath: /etc/puppetlabs/code/modules/site/templates/ntp/ntp.conf.epp
Line: 3
Detail: undefined local variable or method `’servers’' for #<Puppet::Parser::TemplateWrapper:0x34a1bb52>
(file: /etc/puppetlabs/code/modules/site/manifests/profiles/ntp.pp, line: 14, column: 31)
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run