Skip to content

Instantly share code, notes, and snippets.

@lusis
Created November 4, 2010 20:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lusis/663131 to your computer and use it in GitHub Desktop.
Save lusis/663131 to your computer and use it in GitHub Desktop.
##############################################################
## In a given puppet module, you might have something like: ##
##class foo { ##
## $fragments = ["property1", "property2"] ##
## ##
## file { ##
## "/etc/myapp/myapp.config": ##
## ensure => present, ##
## content => template("template.erb"); ##
## } ##
##############################################################
# This is a module specific setting
module_specific_setting = 0
# included from shared setting - property1
some_shared_setting = 1
# included from shared setting - property2
some_other_shared_setting=foobarbaz
logdir=/var/log/myapp
# included from shared setting - property1
some_shared_setting = 1
# included from shared setting - property2
some_other_shared_setting=foobarbaz
logdir=/var/log/myapp
##############################################################
## In a given puppet module, you might have something like: ##
##class foo { ##
## $fragments = ["property1", "property2"] ##
## ##
## file { ##
## "/etc/myapp/myapp.config": ##
## ensure => present, ##
## content => template("template.erb"); ##
## } ##
##############################################################
# This is a module specific setting
module_specific_setting = 0
<% fragments.each do |fragment| -%>
<%= scope.function_template("fragments/#{fragment}.erb") %>
<% end -%>
@jeffmccune
Copy link

How does this differ from using template to concatenate ERB files in the language? Does this pattern allow us to easily "override" parameters, or would you use something like extlookup() for that?

e.g.

$fragments = ["header.erb", "fragments/property1", "fragments/property2", "footer.erb" ]
file {
  "/etc/myapp/myapp.config":
    ensure => present,
    content => template($fragments);
} 

@lusis
Copy link
Author

lusis commented Nov 5, 2010

Well we use cobbler for external node data so that might have been the reason. I'm trying to remember where the headache was but every trick I tried didn't work. The fragments actually map to managment classes in cobbler and have their own set of variables that come from site.pp (bad place, I know).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment