public
Created

Puppet Module : No Code In Data ~ create Facts using URL, File or any System Computation

  • Download Gist
git.pp
Puppet
1 2 3 4 5 6 7 8 9 10
# $MODULEPATH/httpd/manifests/git.pp
 
class httpd::git {
 
file {
"${::conf_dir}/git.conf":
ensure => 'present',
content => template('httpd/mynode.conf.erb'),
}
}
httpd_facts.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
# $MODULEPATH/httpd/lib/facter/httpd_facts.rb
 
require 'facter'
 
###
## data from url, system file or any task/computation can be assigned here for facters
 
facters = {
:conf_dir => '/etc/httpd/conf.d',
:is_cgi => true,
:git_path => '/var/www/git',
:git_url => '/mygit'
}
##
###
 
facters.each_pair do |key, value|
Facter.add(key) do
setcode do
value
end
end
end
mynode.conf.erb
HTML+ERB
1 2 3 4 5 6 7 8 9 10 11
# $MODULEPATH/httpd/templates/mynode.conf.erb
 
Alias <%= git_url %> <%= git_path %>
 
<Directory <%= git_path %>>
<% if is_cgi === 'true' %> # because in Facts any (boolean) value is kept as string
Options +ExecCGI
AddHandler cgi-script .cgi
DirectoryIndex gitweb.cgi
<% end %>
</Directory>
run_puppet.sh
Shell
1
puppet apply --modulepath=$MODULEPATH -e "include httpd::git"

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.