I have a puppet classe with more than 300 parameter (for firewall configuration).
I'm using ini_setting to set different module into the firewall. Currently, for every setting, I need to write a ini_setting command EX :
ini_setting { "my_":
notify => Service['myfirewall'],
ensure => present,
path => '/etc/firewall.conf',
section => '', setting => 'TCP_IN',
value => "\"${tcp_in}\"",
}
Is there a way I could use a each loop to parse all the class parameter at once EX :
$classparam.each | String $fieldname, String $value | {
$param = upcase(${fieldname}),
ini_setting { "my_${fieldname}":
notify => Service['myfirewall'],
ensure => present,
path => '/etc/firewall.conf',
section => '', setting => 'TCP_IN',
value => "\"${value }\"",
}
}
This would take a fer hundred line out of my module, and make it a lot more readable!
Thank you for all input!
↧