Skip to content

Instantly share code, notes, and snippets.

@abhishekkr
Created September 9, 2012 12:07
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abhishekkr/3684010 to your computer and use it in GitHub Desktop.
Save abhishekkr/3684010 to your computer and use it in GitHub Desktop.
Puppet Module : No Code In Data ~ Externalize Data into separately managed CSV files
We can make this file beautiful and searchable if this error is corrected: It looks like row 2 should actually have 1 column, instead of 2. in line 1.
# $MANIFESTPATH/extdatadir/common.csv
httpd_conf_dir,/etc/httpd/conf.d
httpd_is_cgi,true
httpd_git_path,/var/www/git
httpd_git_url,/mygit
We can make this file beautiful and searchable if this error is corrected: It looks like row 2 should actually have 1 column, instead of 2. in line 1.
# $MANIFESTPATH/extdatadir/env_testnode.csv
httpd_git_url,/testgit
# $MODULEPATH/httpd/manifests/git.pp
class httpd::git {
$conf_dir = extlookup('httpd_conf_dir')
$is_cgi = extlookup('httpd_is_cgi')
$path = extlookup('httpd_git_path')
$url = extlookup('httpd_git_url')
file {
"${conf_dir}/git.conf":
ensure => 'present',
content => template('httpd/mynode.conf.erb'),
}
}
# $MODULEPATH/httpd/templates/mynode.conf.erb
Alias <%= url %> <%= path %>
<Directory <%= path %>>
<% if is_cgi === 'true' %> # because from CSV any (boolean) value will be read as string
Options +ExecCGI
AddHandler cgi-script .cgi
DirectoryIndex gitweb.cgi
<% end %>
</Directory>
puppet apply --environment=testnode --modulepath=$MODULEPATH --manifestdir=$MANIFESTPATH $MANIFESTPATH/site.pp
# $MANIFESTPATH/site.pp
$extlookup_datadir = "${settings::manifestdir}/extdatadir"
$extlookup_precedence = ["%{fqdn}", "env_%{environment}", "domain_%{domain}", "common"]
include httpd::git
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment