On Thu, Dec 16, 2010 at 2:57 PM, Tim Watts <t...@dionic.net> wrote:
> Hi Felix,
>
> Thanks for this - I am liking it.
>
>
>>> define remotefile($path, $module, $owner = root, $group = root, $mode
>>> = 0644, $ensure = present) {
>>>   file { $name:
>>>     ensure  =>  $ensure,
>>>     mode    =>  $mode,
>>>     owner   =>  $owner,
>>>     group   =>  $group,
>>>     source  =>  "puppet:///modules/$module/$path",
>>>   }
>>> }
>
> I tweaked it a bit:
>
> define remotefile( $owner = root, $group = root, $mode = 0644, $ensure =
> present) {
>   file { $name:
>     ensure  => $ensure,
>     mode    => $mode,
>     owner   => $owner,
>     group   => $group,
>     source  => "puppet:///files/$name",
>   }
>  }
>
> and
>
> class syslog {
>        remotefile { "/tmp/etc/syslog-ng/syslog-ng.conf": }
> }
>
> which is what I call concise (/tmp intentional).
>
>
>
>>
>> This compells me to elaborate a bit more. The problem with the above is
>> that you cannot have a remotefile that doesn't care about the mode
>> (i.e., let puppet accept whatever mode it finds on the client machine).
>>
>> If you just speicfy
>> remotefile { "/etc/motd": module =>  "all" }
>> the mode will be forced to 0644, which may not be what you want in edge
>> cases.
>>
>> This is the pattern we use for this problem:
>>
>> define remotefile($mode = "") {
>
> Sorry - I don;t understand this - is this pure ruby or puppet language?

Just to indicate it's an optional parameter, since default behavior is
handled as seen below.

>>   if $mode != "" { File { mode =>  $mode } }
>
> If it were ruby, I might have expected File:Stat or whatever - but I can't
> find any docs on the puppet site describing "File".

Resource defaults, definitely a clever use:
http://docs.puppetlabs.com/guides/language_tutorial.html#resource-defaults

> any chance of a quick explanation please?
>
> I sort of see what the intent is - but not how it actually works.
>
>>   file { $name:
>>     source =>  "puppet:///.../$name"
>>   }
>> }
>>
>> Actually, our remotefile has similar support for about *all* parameters
>> that "file" supports, except that owner and group indeed default to root
>> (you would not want to not set those explicitly).
>>
>> Also note that the "path" parameter is optional in our implementation.
>> Normally the URL uses $name, so if you need to override that behaviour,
>> you can fall back to specifying the path. This is handled by if-else
>> logic in the define.
>>
>> Cheers,
>> Felix
>>
>
> Many thanks,
>
> Tim
>
> BTW
>
> I am looking next to try a "define something" to do nodes.pp so I can
> declare "A inherits B" and have it set up some magic that the remotefile
> function can use inherently. Back with more on this if I get something
> working or get stuck...
>
> --
> Tim Watts
> Personal Email
>
> --
> 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.
>
>

-- 
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