Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Puppet: How to concatenate variable and a String

I want to concatenate puppet variable and a string

$agents_location='/home/agent2/adikari5'
file { $agents_location+"/filename.zip":

    mode => "0777",
    owner => 'root',
    group => 'root',
    source => 'puppet:///modules/filecopy/wso2as-5.2.1.zip',
}

As above code I want to concat the $agent_location and rest of the string part to make the path to the file. What is the correct way of doing it ?

like image 515
Malintha Avatar asked Dec 19 '22 14:12

Malintha


1 Answers

You can interpolate variables in a string with ${}:

file { "${agents_locations}/filename.zip":
  ...
}

Note the double quotes. Without them, the path name will be literally what you wrote, i.e. ${agents_locations}/filename.zip instead of /home/agent2/adikari5/filename.zip.

Documentation reference: http://docs.puppetlabs.com/puppet/latest/reference/lang_variables.html#interpolation

like image 119
Emyl Avatar answered Jan 04 '23 18:01

Emyl