使用puppet创build多个目录

我正在尝试使用下列清单创build多个目录

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 

请build议如何解决问题

删除资源标题中的引号,以及不必要的path参数:

 file { $appdirs: ensure => directory, owner => root, group => root, mode => 0644, } 

使用"$appdirs"会创build一个单独的string,其中包含appdirs数组的内容,但是您需要传递一个数组来声明多个资源。

看起来像你需要从appdirsvariables周围删除引号,你不需要明确指定path。

看到这个答案的例子。