On 4 July 2014 22:14, David Schmitt <da...@dasz.at> wrote:

> On 2014-07-04 18:31, Erik Dalén wrote:
>
>> Due to the dynamic scoping of them I only really use them for setting
>> global defaults. And some mechanism for doing that is really needed.
>>
>
> I've used to do that to set file buckets and Exec#path. But importing
> modules really put a stop to that as I saw that I didn't really need that:
>
>  https://github.com/DavidS/dasz-configuration/blob/
>> master/manifests/site.pp
>>
>
>
>
>  Using them inside classes is really mostly syntactic sugar to get the
>> code shorter. But I've also seen them used to conditionally set an
>> attribute. So not set it to value or undef, to set it to value or not
>> set it at all, as that has slightly different semantics. But that would
>> also really be better to do with some sort of postfix if condition in
>> the resource declaration.
>>
>
> Like this:
>
>   file { "/foo": ;}
>
>   if $x { File["/foo"] { source => $x } }
>
> ?
>
> See
>
>  https://github.com/DavidS/dasz-configuration/blob/master/modules/hosting/
>> manifests/customer_service.pp#L17
>>
>
> for a more elaborate example.
>
>
Right, that seems good. Older versions of the concat module used resource
defaults to accomplish this:
https://github.com/puppetlabs/puppetlabs-concat/blob/0.2.0/manifests/fragment.pp#L24-L41
But that was probably for puppet 2.6.x compatibility reasons or something.

-- 
Erik Dalén

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-dev/CAAAzDLeQ5ayYucxxEoRFC%3DeRQGRc%2BMk9s91zcKJrUskP-x1JYw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to