Jean-Baptiste Barth wrote:

I'd like to be able to deploy a skeleton directory through puppet, i.e. puppet deploys it only if it does not exist.
[...]
But I have 2 problems for the moment :
- if I don't set owner/group, it takes uid/gid on the puppetmaster, which does not exist on the node ; if I do set these options, the directory is scanned each time and all files are chown'ed to this user/group, which is absolutely not desired behaviour in my case (puppet should not change ownership for files it doesn't manage in my case...) - I'd like puppet to let user change some files in the skeleton as they want, i.e. skip this directory if it just exists

The second problem you can solve by using the 'replace => false'
parameter to the file type.  However, if the user *removes* one
of the files in the skeleton directory, then Puppet will download
it again, so maybe it isn't quite enough.

And even with 'replace => false', Puppet will manage ownerships
and modes of all files.

One solution is to develop a custom fact that gets set to true
if the target directory already exists, and not set if it doesn't.
Then you can do

    if $dir_opt_foo_data_exists != "true" {
        file {
            "/opt/foo/data": source => ..., recurse => true, ...;
        }
    }

This doesn't scale very well to many directories, though, as you
need one custom fact for each such directory.  Another way is to
do it with an exec:

    exec {
        opt-foo-data:
            command => "wget -r http://.../ && chown -R auser:agroup data",
            cwd => "/opt/foo", path => "/bin:/usr/bin",
            creates => "/opt/foo";
    }

Note the use of the parameter 'creates => "/opt/foo"', which will
make Puppet only run the command if /opt/foo doesn't already exist.

The disadvantage is that you need to configure and run a web server
(or ftp server) somewhere as well.


        /Bellman

--
You received this message because you are subscribed to the Google Groups "Puppet 
Users" group.
To post to this group, send email to puppet-us...@googlegroups.com.
To unsubscribe from this group, send email to 
puppet-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.

Reply via email to