I have the same issue, I basically create an array, that way it cuts it 
down to one FILE, and not the same thing over and over again.


file { ["/blah", "/blah/blah", "/blah/blah/blah", "/blah/blah/blah/blah", 
"/blah/blah/blah/blah/blah"]:
ensure => directory,
owner => "blah",
group => "blah",
mode => 0700,
}

On Monday, April 8, 2013 1:27:11 PM UTC-7, Luca Gioppo wrote:
>
> Can you post a complete example please?
> Thanks
> Luca
>
>
> 2013/4/4 Mike Power <dodt...@gmail.com <javascript:>>
>
>> Actually I found if I created a resource between path and file called 
>> element, I could give it a unique name.  Then inside the body I could check 
>> to see if the File is declared, if not I could declare it.  
>>
>> On Thursday, April 4, 2013 9:23:54 AM UTC-7, Mike Power wrote:
>>>
>>> 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 puppet-users...@googlegroups.com <javascript:>.
>> To post to this group, send email to puppet...@googlegroups.com<javascript:>
>> .
>> Visit this group at http://groups.google.com/group/puppet-users?hl=en.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>  
>>  
>>
>
>

-- 
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 puppet-users+unsubscr...@googlegroups.com.
To post to this group, send email to puppet-users@googlegroups.com.
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