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 ?
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With