Puppet right now requires every element of a path to have an individual 
file definition.  This makes it had to take an arbitrary path as a 
parameter.  You are forced to require your client to make the entire path 
structure for you or instead you use an exec resource and call mkdir -p.  
Using an exec resource does not generate an File resources so autorequire 
does not work.

I didn't like this, I wanted to be able to once specify a path and have 
puppet do that autorequire as needed.

Something like:
    path {"/blah/blah/blah/and/blah":
    }


In order to make this happen I would have to manually define each file:
    file {"/blah/":
        ensure      => directory,
    }

    file {"/blah/blah/":
        ensure      => directory,
    }

    file {"/blah/blah/blah/":
        ensure      => directory,
    }

    file {"/blah/blah/blah/and/":
        ensure      => directory,
    }

    file {"/blah/blah/blah/and/blah/":
        ensure      => directory,
    }

Of course there is a short hand for this:
    file {["/blah/", "/blah/blah/", "/blah/blah/blah/", 
"/blah/blah/blah/and/","/blah/blah/blah/and/blah/"]:
        ensure      => directory,
    }

Then it occurred to me I could parse the path and produce the array of 
elements needed.  Something like:
    $path = "/blah/blah/blah/and/blah"
    $file_list = split($path, $file_separator)
    $paths = inline_template('<% parent = nil %><%=@file_list.collect{ 
|file| parent.nil? ? parent = "#{@file_separator}":parent = 
"#{parent}#{file}#{@file_separator}"}.join(@path_separator) %>')
    $path_list = split($paths, $path_separator)
    file{$path_list:
        ensure      => directory,
    }

This works great.... once.  Then you get errors like:
    Error: Duplicate declaration: File[/]

If there anyway to trim down the produced array by removing the resources 
that already exist?







-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/puppet-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to