I am trying to create multiple directories and then copy files to each of the directories . For that I have created the following resource
$dirs=myapp
$appdirs = [ "/data/tomcat/$dirs/conf", "/data/tomcat/$dirs/config", "/data/tomcat/$dirs/libs","/data/tomcat/$dirs/deploy","/data/tomcat/$dirs/webapps","/data/tomcat/$dirs/temp","/data/tomcat/$dirs/work" ]
file { "/data/tomcat/$dirs":
path => "/data/tomcat/$dirs",
ensure => "directory",
owner => "root",
group => "root",
}
file { $appdirs:
ensure => "directory",
owner => "root",
group => "root",
}
file { "/data/tomcat/$dirs/conf/":
path => "/data/tomcat/$dirs/conf/",
ensure => "present",
recurse => "true",
source => "puppet:///modules/tomcat8/conf/"
}
file { "/data/tomcat/$dirs/config":
path => "/data/tomcat/$dirs/config/",
ensure => "present",
recurse => "true",
source => "puppet:///modules/tomcat8/config/"
}
}
But I am getting the error `already defined` as shown below
Error: Failed to apply catalog: Cannot alias File[/data/tomcat/myapp/conf/] to ["/data/tomcat/myapp/conf"] at /etc/puppetlabs/code/environments/production/manifests/classes/app.pp:20; resource ["File", "/data/tomcat/myapp/conf"] already declared at /etc/puppetlabs/code/environments/production/manifests/classes/app.pp:14
My modules directory is as follows:
/etc/puppetlabs/code/environments/production/modules/tomcat8/conf/files/
I need to copy files using the second resource `file { "/data/tomcat/$dirs/conf/": `to the destination directory after it is created using the first resource `file { $appdirs:} ` but since it is already defined in first case , it is failing for me . I am looking for workarounds so that I can create the directories and then copy files in it .
↧