题
我想连接puppet变量和一个字符串
$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',
}
如上代码,我想连接string agent_location和字符串部分的其余部分,以创建文件的路径。正确的做法是什么?
解决方案
您可以在字符串中插入变量 ${}
:
file { "${agents_locations}/filename.zip":
...
}
注意双引号.如果没有它们,路径名称将是您所写的,即 ${agents_locations}/filename.zip
而不是 /home/agent2/adikari5/filename.zip
.
文件参考:http://docs.puppetlabs.com/puppet/latest/reference/lang_variables.html#interpolation
不隶属于 StackOverflow