Created
September 9, 2012 15:16
-
-
Save abhishekkr/3684968 to your computer and use it in GitHub Desktop.
Puppet Module : No Code In Data ~ create Facts using URL, File or any System Computation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# $MODULEPATH/httpd/manifests/git.pp | |
class httpd::git { | |
file { | |
"${::conf_dir}/git.conf": | |
ensure => 'present', | |
content => template('httpd/mynode.conf.erb'), | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# $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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# $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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
puppet apply --modulepath=$MODULEPATH -e "include httpd::git" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment