Default values for properties - good or goblin?

25 views
Skip to first unread message

Felix Frank

unread,
Feb 9, 2014, 7:17:10 PM2/9/14
to puppe...@googlegroups.com
Hi,

today I butted heads with yet another cron issue [1] that was caused by
the fact that the cron type specifies a default value for the user
property. It made me think of a fundamental issue I had jotted down some
time ago in a gist [2].

I propose that default values for properties are dangerous, at least in
the way they work right now. What happens is that a manifest that does
not specify a value for a property that has a default value leads to a
catalog with this default as the should-value for that property. See the
gist for an example. Puppet will mercilessly sync systems to the default
values.

As far as I can tell, the defaults are only necessary for cases in which
ensure changes from absent to present (or another non-absent value, for
some types). Would it make sense to try and limit their use to exactly
those times?

Cheers,
Felix

[1] https://tickets.puppetlabs.com/browse/PUP-1624
[2] https://gist.github.com/ffrank/8327298

Andy Parker

unread,
Feb 10, 2014, 1:16:40 PM2/10/14
to puppe...@googlegroups.com
On Sun, Feb 9, 2014 at 4:17 PM, Felix Frank <Felix...@alumni.tu-berlin.de> wrote:
Hi,

today I butted heads with yet another cron issue [1] that was caused by
the fact that the cron type specifies a default value for the user
property. It made me think of a fundamental issue I had jotted down some
time ago in a gist [2].

I propose that default values for properties are dangerous, at least in
the way they work right now. What happens is that a manifest that does
not specify a value for a property that has a default value leads to a
catalog with this default as the should-value for that property. See the
gist for an example. Puppet will mercilessly sync systems to the default
values.
 
 
As far as I can tell, the defaults are only necessary for cases in which
ensure changes from absent to present (or another non-absent value, for
some types). Would it make sense to try and limit their use to exactly 
those times?


Are you asking about in general or just for the specific case of the ssh_authorized_keys code?
 

--
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+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-dev/52F81A86.70000%40Alumni.TU-Berlin.de.
For more options, visit https://groups.google.com/groups/opt_out.



--
Andrew Parker
Freenode: zaphod42
Twitter: @aparker42
Software Developer

Join us at PuppetConf 2014September 23-24 in San Francisco - http://bit.ly/pupconf14

Felix Frank

unread,
Feb 10, 2014, 3:44:42 PM2/10/14
to puppe...@googlegroups.com
On 02/10/2014 07:16 PM, Andy Parker wrote:
>
> As far as I can tell, the defaults are only necessary for cases in
> which
> ensure changes from absent to present (or another non-absent
> value, for
> some types). Would it make sense to try and limit their use to
> exactly
>
> those times?
>
>
> Are you asking about in general or just for the specific case of the
> ssh_authorized_keys code?
Yes, I think this is a general issue we're facing with all types.

Thanks,
Felix

John Bollinger

unread,
Feb 10, 2014, 4:22:04 PM2/10/14
to puppe...@googlegroups.com


On Sunday, February 9, 2014 6:17:10 PM UTC-6, Felix Frank wrote:
Hi,

today I butted heads with yet another cron issue [1] that was caused by
the fact that the cron type specifies a default value for the user
property. It made me think of a fundamental issue I had jotted down some
time ago in a gist [2].

I propose that default values for properties are dangerous, at least in
the way they work right now. What happens is that a manifest that does
not specify a value for a property that has a default value leads to a
catalog with this default as the should-value for that property. See the
gist for an example. Puppet will mercilessly sync systems to the default
values.

As far as I can tell, the defaults are only necessary for cases in which
ensure changes from absent to present (or another non-absent value, for
some types). Would it make sense to try and limit their use to exactly
those times?



Well, almost everywhere that a type does not require a parameter or property to be explicitly declared, there has to be at least a de facto default that is used if the resource must be transitioned from absent to some form of present.  After that, however, it is a general, longstanding Puppet principle that Puppet only manages the details of target nodes that you instruct it to manage (even if that principle is not universally followed).

At minimum, then, I'd say that there need to be -- and to some extent there are -- defaults that apply only to resource creation.  It does not necessarily follow that more broadly-scoped defaults are always poor practice, but after some reflection, I'm having difficulty coming up with satisfactory arguments against that proposition.


John

Reply all
Reply to author
Forward
0 new messages