Ask Your Question
0

Creating multiple directories using puppet failing

asked 2017-04-13 01:09:34 -0500

queszama gravatar image

I am trying to create multiple directories using the following manifests

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,
   }
 }

But when I execute it is failing with the below error

     # 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

Please suggest how to resolve the issue

edit retag flag offensive close merge delete

3 Answers

Sort by ยป oldest newest most voted
0

answered 2017-04-13 09:41:17 -0500

puser gravatar image
$appdirs = [ "/data/tomcat/$dirs/conf", "/data/tomcat/$dirs/config", "/data/tomcat/$app8/libs","/data/tomcat/$app8/deploy","/data/tomcat/$app8/webapps","/data/tomcat/$app8/temp","/data/tomcat/jacplus8/work" ]

$appdirs.each | $app | {
   file { $app: 
      ensure => directory,
      owner => 0,
      group => 0,
   }
}
edit flag offensive delete link more
0

answered 2017-04-13 04:45:34 -0500

queszama gravatar image

Ok....I was able to fix this... The path variable does not seems to work with arrays . My new rules are as follows which worked for me.

   class app {

    $dirs=app8
    class app {
    $appdirs = [ "/data/tomcat/$dirs/conf", "/data/tomcat/$dirs/config", "/data/tomcat/$app8/libs","/data/tomcat/$app8/deploy","/data/tomcat/$app8/webapps","/data/tomcat/$app8/temp","/data/tomcat/jacplus8/work" ]

  file { "/data/tomcat/$dirs":
     path => "/data/tomcat/$dirs",
     ensure => "directory",
     owner => "root",
     group => "root",
}
 file { $appdirs:
   ensure => directory,
   owner => "root",
   group => "root",
  }
}
edit flag offensive delete link more
0

answered 2017-04-13 01:52:54 -0500

greynolds gravatar image

https://www.puppetcookbook.com/posts/...

class directory_tree {

# create a directory tree, list the directories in order # and puppet will 'do the right thing'. file { [ '/usr/local/whisper/', '/usr/local/whisper/2.0', '/usr/local/whisper/2.0/bin', '/usr/local/whisper/2.0/log' ]: ensure => 'directory', }

# or you can assign them to a variable and use them in the resource $whisper_dirs = [ '/usr/local/whisper/', '/usr/local/whisper/2.0', '/usr/local/whisper/2.0/bin', '/usr/local/whisper/2.0/log', ]

file { $whisper_dirs: ensure => 'directory', owner => 'root', group => 'wheel', mode => '0750', }

edit flag offensive delete link more

Comments

I followed that document only to prepare my manifests rule

queszama gravatar imagequeszama ( 2017-04-13 01:56:15 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 2017-04-13 01:09:34 -0500

Seen: 66 times

Last updated: Apr 13