[Mageia-sysadm] [sysadmin-commits] [2736] do not explictely set the same value as default

Michael Scherer misc at zarb.org
Sun Apr 15 14:35:57 CEST 2012


Le dimanche 15 avril 2012 à 02:41 +0200, nicolas vigier a écrit :
> On Sun, 15 Apr 2012, root at mageia.org wrote:
> 
> > Revision: 2736
> > Author:   misc
> > Date:     2012-04-15 01:45:48 +0200 (Sun, 15 Apr 2012)
> > Log Message:
> > -----------
> > do not explictely set the same value as default
> 
> I don't see the use of not explicitely setting the values and rely on
> default value. Actually this make the modules unusable outside mageia
> servers, because default values can be different.

That's default in upstream puppet, so that would work almost everywhere.

Package without "ensure => installed" are installed on all version of
puppet. 

https://github.com/puppetlabs/puppet/blob/master/lib/puppet/type/package.rb#L113

I have yet to see someone explicitly changing the default value.

File will be root owned if nothing have been specified, since the agent
is running as root ( and if this is not running as root as I have heard
being done at a customer office, forcing the owner would result in a
error, so the unusability argument can be more complex than "default
should be avoided" )

And ensure => present is implicit if content is set.


> In my opinion we should always explicitly set the values when they are
> important, and only use default value when we don't care about the
> value.


Defaults are made to avoid endless duplication of useless source code.
We did the same for rpm. First, every file should have had %attr, then
it became %defattr at the beggining of %files ( I guess that was even
before the first version of rpm ), then %defattr(-,-), then %defattr got
removed. All of this because shorter spec without the same boilerplate
are easier to maintain, and less tedious to write. 

That's just following the DRY principle.

We also do not repeat file declaration from rpm to make sure that for
example /usr/bin/svn is executable because we assume that's the default
( and we also do not take in account in our script that it could be
anywhere in the path ). 
We do not explicitly give the content of every config file in rpm for
the same reason, because we assume the default are correct. So basically
using default value is just one step further in the same direction.

Out of the box reusability is nice on the paper, but in practice, this
doesn't happen, because we do not care about portability ( like package
name accros diverse distribution or even OS ), genericity ( service
naming in our architecutre, like the ldap server, the prostgres one, and
there is not even documentation about it ) or even puppet version ( we
do no test on previous version or attempt to be compatible ), repository
layout ( cause 1 big svn is not the most reusable way of distributing
module, but the simplest for a infra ), etc.


IMHO, out of the box reusability lead to complex code, and except for
trivial service like xinetd, at or cron, people will always have to
modify something to suit them. So in the rare event that someone decide
that default value for package is "uninstalled" or something equally
strange and this person has the same exact architecture than us except
this detail, yes, this will not work out of the box, but in exchange of
this sacrifice, we have shorter manifests, and less repetition. 


Taking advantage of the default is also a recommendation that I found in
a internal audit done by puppet labs for my employer setup, the main
idea is that it is faster to write, faster to read and understand, and
the less code we write, the less error we can place by inadvertence.

And for the sake of coherence, the whole repository was cleaned a few
months ago to have manifests without the same boilerplate, and no one
commented, and there is nothing special in repoctl to be different. 
-- 
Michael Scherer



More information about the Mageia-sysadm mailing list