Ask Your Question

Is it possible to have file resource name value as an array [closed]

asked 2017-04-18 07:17:27 -0500


I want to set file ressource like that :

classe llibrenms::agent {

$scripts = ['dpkg','bind'] file {"/usr/lib/checkmkagent/local/${scripts}": source => "/opt/librenms-agent/agent-local/${scripts}", }

But it gave me :

Failed to apply catalog: Parameter source failed on File[/usr/lib/checkmkagent/local/[dpkg, bind]]: Failed to convert '/opt/librenms-agent/agent-local/[dpkg, bind]' to URI: bad component(expected absolute path component): /opt/librenms-agent/agent-local/[dpkg,%20bind] at /etc/puppetlabs/code/environments/production/modules/snmp/manifests/init.pp:126

What can I do to resolve this ?

Thank you !


edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by ndevouge
close date 2017-04-20 04:33:47.483164

2 Answers

Sort by ยป oldest newest most voted

answered 2017-04-20 03:42:53 -0500

fvoges gravatar image

When you use an array for the title, you can not use variable interpolation. And all the attributes need to be the same for all the resources declared using the array.

In Puppet 4, you can use code like this to do what you want:

$scripts = ['dpkg','bind']
$scripts.each | String $script | {
  file { "/usr/lib/checkmkagent/local/${script}":
    ensure => file,
    source => "/opt/librenms-agent/agent-local/${script}", 
edit flag offensive delete link more


In puppet 3, you were able to use the methods to achieve something similar

DarylW gravatar imageDarylW ( 2017-04-21 10:22:29 -0500 )edit

answered 2017-04-20 04:33:24 -0500

Wow perfect ! Thank you for your response, it works perfectly :)

edit flag offensive delete link more

Question Tools


Asked: 2017-04-18 07:17:27 -0500

Seen: 21 times

Last updated: Apr 20