我正在尝试使用以下清单创建多个目录
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
请建议如何解决这个问题
答案1
删除资源标题中的引号,以及不必要的path
参数:
file { $appdirs:
ensure => directory,
owner => root,
group => root,
mode => 0644,
}
使用"$appdirs"
创建一个包含 appdirs 数组内容的字符串,但您需要传递一个大批本身声明多个资源。
答案2
看起来您需要从 appdirs 变量周围删除引号,并且您不需要明确指定路径。
看这个答案举个例子。