I am using Puppet to manage the configurations of some servers. One of the tasks is to create a specific folder structure under /www
for hosting our applications.
But lately, we've had this server where /www
is just a symbolic link to another directory (had to do that because of storage shortage)
$ ls -l /www
lrwxrwxrwx 1 root root 13 Oct 25 15:33 /www -> /storage/www/
And we've been using this so far to manage directories:
file { $path:
ensure => directory,
owner => user,
group => group,
mode => 'a=rx,u+w'
}
The issue with this specific server, is that when running Puppet, the /www
symlink gets deleted and Puppet creates a new regular directory under /www
instead. And that breaks the applications for us unless we intervene manually to create the symbolic link again.
My question:
Does someone know of a way that makes Puppet not delete the symlink and just treat it as a directory: If no /www
directory or no /www
symlink exists, create the /www
directory, else do nothing?
Best Answer
The short answer is to change
into
By using
ensure => directory
, you are telling puppet that you want a directory, and that anything else it finds (like a file or symbolic link) it should clobber and replace with the directory. By usingensure => link
, you'll be telling puppet that you want a symbolic link that points to the value oftarget
, which in turn could be a directory, a file, or a device. Depending on what you're doing, you may need to create a file type (usingensure => directory
) on your target, if you need puppet to manage it.I would strongly recommend you read the documentation for the file type to better understand how to use it.
Edit:
To distinguish between different servers, you'll want to use individual
node
definitions for your different servers. You could essentially do the following to get what you want: