I want to create the directory structure /var/www/apps/example/current/public
if it doesn't exist using puppet. If it already exists I don't want to purge the contents of the directories. How do I do this? Below is what I have so far:
file { "/var/www/apps/example/current/public":
owner => 'deploy',
group => 'users',
ensure => "directory",
purge => false,
recurse => true
}
This gives me
Cannot create /var/www/apps/example/current/public; parent directory /var/www/apps/example/current does not exist
The recurse
parameter does not allow you to create parent directories. It is used to enforce property values such as owner
, mode
etc. on directory contents and subdirectories recursively.
file { '/var/www':
owner => 'www-data',
recurse => true,
}
As a matter of fact, Puppet currently cannot automatically create all parent directories. You should add all relevant directories as resources instead.
file { [ '/var/www/apps',
'/var/www/apps/example',
'/var/www/apps/example/current',
'/var/www/apps/example/current/public', ]:
ensure => directory,
...
}
Existing content will remain unmolested. There is no need to pass the purge
parameter.