[Mageia-sysadm] Keep puppet module generic without hardcoding domain name
Michael Scherer
misc at zarb.org
Mon Nov 15 18:03:46 CET 2010
Hi,
Looking after most commits, I see that we often hardcode the domain name
in the puppet manifest and template.
I think we should avoid for various reasons :
- hard coding anything is never good
- if one day we fork again, or if we are forced to change project name
( both have occurred in the past for mandriva, so maybe we could be
proactive this time ), this would be easier for us ( or them, depending
on the side of the fork we are ).
- this greatly enhance the module reusability ( IE, I cut and past some
module that I use on my server )
- this is not really complex to achieve, thanks to templating
and the more important reason :
- this allow us to set up test VMs/servers without fiddling with DNS too
much, and prevent stupid errors ( like changing /etc/hosts and
forgetting this was changed ).
So, if you agree with me, and if you see mageia.org in some templates
files ( except in bind for obvious reason ), just replace this with <%=
domain %>. See for example commit 221.
This is the ERB syntax ( erb being the template engine of ruby and
puppet ) for expanding the variable, see
http://en.wikipedia.org/wiki/ERuby
The list of variable to use can be found with the facter command.
And for the ldap dc=mageia,dc=org, we can either add a variable to
facter ( this would be cleaner, but more complex
http://projects.puppetlabs.com/projects/1/wiki/Adding_Facts ), or use
this in the template :
<%
dc_suffix = 'dc=' + domain.gsub('.',',dc=')
%>
<%= dc_suffix %>
See commit 211 for example on how do this.
Of course, if there is something I missed, do not hesitate to tell.
--
Michael Scherer
More information about the Mageia-sysadm
mailing list