I am getting the following error during directory creation using file resource
Error: Cannot create /data/tomcat/${dirsname}/conf; parent directory /data/tomcat/${dirsname} does not exist
Error: /Stage[main]/App/File[/data/tomcat/${dirsname}/conf]/ensure: change from absent to directory failed: Cannot create /data/tomcat/${dirsname}/conf; parent directory /data/tomcat/${dirsname} does not exist`
Error: Cannot create /data/tomcat/$dirsname/config; parent directory /data/tomcat/$dirsname does not exist
Error: /Stage[main]/App/File[/data/tomcat/$dirsname/config]/ensure: change from absent to directory failed: Cannot create /data/tomcat/$dirsname/config; parent directory /data/tomcat/$dirsname does not exist`
But technically the directories are getting created as can can be seen from the puppet
command output
Notice: /Stage[main]/App/File[/data/tomcat/$dirsname/conf/]/ensure: created
Notice: /Stage[main]/App/File[/data/tomcat/jacplus8/conf/context.xml]/ensure: defined content as '{md5}ba798c2de6dd554035c05352891a0d07'
Notice: /Stage[main]/App/File[/data/tomcat/jacplus8/conf/server.xml]/ensure: defined content as '{md5}6298e53557ead6855cef9bcbb082a074'`
Notice: /Stage[main]/App/File[/data/tomcat/$dirsname/config/]/ensure: created
Notice: /Stage[main]/App/File[/data/tomcat/jacplus8/config/runtime.settings]/ensure: defined content as '{md5}2e2596f0f9107c8cfc783da3d5004dae'`
I checked the directory structure , the directories are available but not sure why it is showing the error messages. My manifests rule are as follows
class app {
$dirsname=myapp8
file { 'directory':
path => "/data/tomcat/${dirsname}/",
ensure => "directory",
owner => "root",
group => "root",
}
file { '/data/tomcat/${dirsname}/conf':
ensure => "directory",
owner => "root",
group => "root",
require => File['directory'],
}
file { '/data/tomcat/$dirsname/config':
ensure => "directory",
owner => "root",
group => "root",
require => File['directory'],
}
file { '/data/tomcat/$dirsname/conf/':
path => "/data/tomcat/$dirsname/conf/",
ensure => "present",
recurse => "true",
source => "puppet:///modules/conf/"
}
file { '/data/tomcat/$dirsname/config/':
path => "/data/tomcat/$dirsname/config/",
ensure => "present",
recurse => "true",
source => "puppet:///modules/config/"
}
}
Replace the single quotes with double quotes, then the variable will be interpolated. Do this on all lines with single quotes and variables (there are four).
As you can see from the log, it's creating directories with the variable name in it, not the directory with the variable replaced: