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
--
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/puppet-users/2580881E-185B-41FD-87E7-04FDB93C5E4B%40gmail.com.