I am creating a small freeradius module in puppet. I have some problems creating the client.conf file, which should look something like this:
client switch01 {
ipaddr = 10.10.10.50
secret = secret
shortname = switch01
}
client switch02 {
ipaddr = 10.10.10.51
secret = secret
shortname = switch02
}
So I am trying to create this with a template file clients.erb. These are the files:
yaml file:
test_freeradius::clients:
'switch01':
ip: '10.10.10.50'
secret: 'secret'
shortname: 'switch01'
'switch02::
ip: '10.10.10.51'
secret: 'secret'
shortname: 'switch02'
define:
define test_freeradius::clients (
$ip,
$secret,
$shortname,
) {
include test_freeradius::service
if ! defined(File['/etc/freeradius/clients.conf']){
file { '/etc/freeradius/clients.conf' :
ensure => 'file',
owner => 'root',
group => 'freerad',
mode => '0640',
content => template('test_freeradius/clients.erb'),
require => Class['test_freeradius::install'],
notify => Service['freeradius'],
}
}
$data = hiera_hash('test_freeradius::clients')
}
init.pp:
class test_freeradius {
create_resources(test_freeradius::clients, $data)
}
I could create one client like this:
client <%= @shortname %> {
ipaddr = <%= @ip %>
secret = <%= @secret %>
shortname = <%= @shortname %>
}
but I couldn't achieve creating multiple clients! at the end I need to create 10 clients.
This didn't work:
<% test_freeradius::clients.each do |key,value| -%>
client <%= key %> {
ipadd = <%= value['ip'] %>
asecret = <%= value['secret'] %>
shortname = <%= value['shortname'] %>
}
<% end -%>
My question is how could I iterate over the hash to create the client.conf file?
Thank you very much!