我正在尝试使用以下清单创建多个目录
class app {
$dirs = app8
$appdirs = ['/data/tomcat/app8/conf', '/data/tomcat/app8/config', '/data/tomcat/app8/libs', '/data/tomcat/app8/deploy', '/data/tomcat /app8/webapps', '/data/tomcat/app8/temp', '/data/tomcat/app8/work']
file { "/data/tomcat/$dirs":
path => "/data/tomcat/$dirs",
ensure => directory,
owner => root,
group => root,
}
file { "$appdirs":
path => '$appdirs',
ensure => directory,
owner => root,
group => root,
mode => 0644,
}
}
但是当我执行它失败并出现以下错误
# puppet agent --verbose --no-daemonize --onetime
Info: Using configured environment 'production'
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Caching catalog for node-003.wiley.com
Error: Failed to apply catalog: Parameter path failed on File[[/data/tomcat/app8/conf, /data/tomcat/app8/config, /data/tomcat/app8/libs, /data/tomcat/app8/deploy, /data/tomcat/app8/webapps, /data/tomcat/app8/temp, /data/tomcat/app8/work]]: File paths must be fully qualified, not '$appdirs' at /etc/puppetlabs/code/environments/production/manifests/classes/app.pp:15
请建议如何解决问题
去掉资源标题的引号,去掉不必要的
path
参数:Using
"$appdirs"
创建了一个字符串,其中包含 appdirs 数组的内容,但您需要传递一个数组本身来声明多个资源。看起来您需要从 appdirs 变量周围删除引号,并且不需要显式指定路径。
有关示例,请参见此答案。