templatizing a configuration file

31 views
Skip to first unread message

Paolo Supino

unread,
Jul 4, 2014, 8:13:44 AM7/4/14
to puppet...@googlegroups.com
Hi

I want to templatize (we use hiera with yaml backend) a configuration file that has the following content:
-------------------
include-and-override=${configDir}/al-runtime.conf
include-and-override=${configDir}/al-ldap.conf
include-and-override=${configDir}/al-cluster.conf
include-and-override=${configDir}/al-jaas.conf
include-and-override=${configDir}/al-internal.conf
include-and-override=${configDir}/al-external.conf
-------------------

 The number of lines and content of the include-and-override directive changes between systems... 

Can it be done? 




TIA 
Paolo

Christopher Wood

unread,
Jul 4, 2014, 12:54:45 PM7/4/14
to puppet...@googlegroups.com
If I were implementing this I would put a list of files in hiera and have my template dump the list into my file. My untested example is below.

Hiera:

---
psconfs:
- al-runtime.conf
- al-ldap.conf
- al-cluster.conf

Puppet class (puppet 3 or higher):

class psthing ($psconfs = []) {
file { '/path/to/conf':
content => template('psthing/mytemplate.erb'),
}
}

Template:

<% @psconfs.each do |file| %>
include-and-override=${configDir}/<%= file %>
<% end %>


There's a similar example here:

http://docs.puppetlabs.com/learning/templates.html#editing-the-templates
> --
> You received this message because you are subscribed to the Google Groups
> "Puppet Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [1]puppet-users...@googlegroups.com.
> To view this discussion on the web visit
> [2]https://groups.google.com/d/msgid/puppet-users/CA%2BB25Bw%2B_g4TQq7eUsHRzLD0JhHYOaerjVep11dYuAZNmu96Yg%40mail.gmail.com.
> For more options, visit [3]https://groups.google.com/d/optout.
>
> References
>
> Visible links
> 1. mailto:puppet-users...@googlegroups.com
> 2. https://groups.google.com/d/msgid/puppet-users/CA%2BB25Bw%2B_g4TQq7eUsHRzLD0JhHYOaerjVep11dYuAZNmu96Yg%40mail.gmail.com?utm_medium=email&utm_source=footer
> 3. https://groups.google.com/d/optout

Paolo Supino

unread,
Jul 7, 2014, 7:11:32 AM7/7/14
to puppet...@googlegroups.com
Hi Christopher 

Thanx for the reply :) 

If anyone ever looks for a similar problem... 
Someone (don't remember the user's NIC, sorry) on Puupet's IRC channel suggested using Puppet's template iteration (as explained  here: http://docs.puppetlabs.com/guides/templating.html#iteration). 








Paolo 


To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/20140704125434.GB24862%40iniquitous.heresiarch.ca.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages