Martin Alfke
unread,Apr 29, 2020, 1:39:43 PM4/29/20Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Puppet Users
Hi,
we want to make use of the splat operator and extend the list of parameters:
#site/profile/manifests/files.pp
class profile::files (
Hash $files = {},
){
$files.each |String $key, Hash $params| {
$_template = $params['template']
$_value = delete($params, 'template')
notify { 'template':
message => $_template,
}
notify { '_value':
message => $_value,
}
file { $key:
* => $_value,
content => epp($_template),
}
}
}
#data/common.yaml
---
profile::files::files:
'/tmp/foo':
ensure: file,
mode: '0644'
template: 'profile/file_template.epp'
Puppet agent run compains:
Error: Failed to apply catalog: Validation of File[/tmp/foo] failed: You cannot specify more than one of content, source, target (file: /etc/puppetlabs/code/environments/production/site/profile/manifests/files.pp, line: 15)
When removing the file resource, the notify output looks OK:
Notice: profile/file_template.epp
Notice: /Stage[main]/Profile::Files/Notify[template]/message: defined 'message' as 'profile/file_template.epp'
Notice: {"ensure"=>"file,", "mode"=>"0644"}
Notice: /Stage[main]/Profile::Files/Notify[_value]/message: defined 'message' as {
'ensure' => 'file,',
'mode' => '0644'
}
Notice: Applied catalog in 36.38 seconds
What am I missing or doing wrong?
Thanks,
Martin