John,

I think where you are going might be similar to a thought I had.  Your code 
is a bit confusing to me and I don't know exactly what it is trying to do. 
  I don't know yet what regsubs means, nor the ^ or \0/ mean.  I will look 
it up and try to figure it out.  

My thoughts on this were (I'm using pseudocode and not sure if this is 
possible, but I am sure you will understand where I am going)

for f in ".../Preferences/"  #Read each file and folder in 
/modules/name_of_module_files/Preferences on Pupppet Master
do
file { ".../Preferences/${f}" :  #Every file and folder would have a unique 
name
  source => "puppet:///modules/${module_name}/Preferences/${f}",  #Every 
source would be unique file and folder in Preferences directory of Master
}
done

So, is it possible in puppet to loop a resource based on the contents of a 
directory?  My initial search has come up empty.  I would think this would 
accomplish what I want, and not have a declaration error.  


On Wednesday, September 24, 2014 9:52:40 AM UTC-5, jcbollinger wrote:
>
>
>
> On Tuesday, September 23, 2014 6:35:53 PM UTC-5, Neil - Puppet List wrote:
>>
>> file { "/System/Library/User 
>> Template/English.lproj/Library/Preferences/${source}" :  # the source is 
>> the file from the line directly below, this seems true as the correct files 
>> copy when I have only 
>>
>> No its just not like that
>>
>> $source would need to be defined in or passed to the scope your file 
>> resource is in.
>> It does not refer to the source parameter to the file resource itself.
>>
>
> In particular, in the example code it evaluates to an empty string.  
> That's why the files are going to the expected location when the define is 
> used only once, and why there is a duplicate resource when the define is 
> used more than once.
>
>  
>
>> To try and get back on the right track i suggest you try just putting two 
>> files in place one from each calling class.
>>
>> I really don't think a recursive directory is what you want. And I don't 
>> think having two of them will ever work.
>>
>
> No, having two declarations of the Preferences directory will never work, 
> but see below.
>
>  
>
>> You should be specifying the names of the individual files.
>>
>
> That is the way I would recommend doing it.  Recursive directories cause 
> no end of headaches.
>
> Nevertheless, although you cannot declare the directory multiple times, 
> you can give it it multiple source directories and instruct it to use them 
> all.  That would be closer to the approach currently being attempted.  It 
> might look something like this:
>
> #
> # Class parameter $applications is expected to provide either
> # a single application (module) name or an array of such names.
> #
> class mac_managed_preferences($applications) {
>   $preference_sources = regsubst($applications, '^.*$', 
> 'puppet:///modules/\0/Preferences')
>
>   file { '/System/Library/User Template/English.lproj/Library/Preferences':
>     ensure => 'directory',
>     owner => 'root',
>     group => 'wheel',
>     mode => '0600',
>     recurse => true,
>     source => $preference_sources,
>     sourceselect => 'all'
>   }
> }
>
>
> John
>
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/929c02fe-171d-46c4-b6db-e7197ca95a78%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to