The whole VERY OLD rant is here http://projects.puppetlabs.com/issues/86
Why on earth in 8 years the Puppet Gods have kept ignoring this very basic and common need, they only know.
In a nutshell, I have a variable
$mypath='/opt/oracle/fmw11_1_1_6'
file { "$mypath":
ensure => directory,
owner => 'soa'
}
This will of course fail if /opt and /opt/oracle have not been already defined.
Of course since $mypath is a configuration value there is no way I can hardcode all the parents directories.
Hence I am screwed, and Puppet doesn't offer me any way around.
I can think of only one elegant way, that is writing a Ruby function (I am not good in Puppet stinky DSL) "pathExpand" to transform a full path into an array of his components:
assert [ '/opt', '/opt/oracle', '/opt/oracle/fmw11_1_1_6' ] = pathExpand('/opt/oracle/fmw11_1_1_6')
and a define "conditionalDirectory($mypath ):
if (! defined($mypath)) {
file { "$mypath":
ensure => directory,
}
}
All this sucks, but not as much as Puppet DSL anyway.
Why on earth in 8 years the Puppet Gods have kept ignoring this very basic and common need, they only know.
In a nutshell, I have a variable
$mypath='/opt/oracle/fmw11_1_1_6'
file { "$mypath":
ensure => directory,
owner => 'soa'
}
This will of course fail if /opt and /opt/oracle have not been already defined.
Of course since $mypath is a configuration value there is no way I can hardcode all the parents directories.
Hence I am screwed, and Puppet doesn't offer me any way around.
I can think of only one elegant way, that is writing a Ruby function (I am not good in Puppet stinky DSL) "pathExpand" to transform a full path into an array of his components:
assert [ '/opt', '/opt/oracle', '/opt/oracle/fmw11_1_1_6' ] = pathExpand('/opt/oracle/fmw11_1_1_6')
and a define "conditionalDirectory($mypath ):
if (! defined($mypath)) {
file { "$mypath":
ensure => directory,
}
}
All this sucks, but not as much as Puppet DSL anyway.