apache puppet module (example)

(a)
init.pp (/etc/puppet/modules/apache/manifests)

class apache {
 
	package {
			'apache2':
			ensure => installed
 
		}
 
	package {
			'libapache2-mod-python':
			ensure => installed,
			notify =>  Exec["reload-apache2"],
			require => Package["apache2"],
 
		}
 
	service { "apache2":
		ensure => running,
		hasstatus => true,
		hasrestart => true,
		require => Package["apache2"],
 
                }
 
	file { "/etc/apache2/sites-available/debian.fosiul.lan":
 
		ensure => present,
		source => "puppet://$servername/modules/apache/scripts/debian.fosiul.lan",
		owner => root,
                group => root,
		replace => true,
		force =>true
 
		}
 
	file { "/etc/apache2/sites-available/web1.fosiul.lan":
 
                ensure => present,
                source => "puppet://$servername/modules/apache/scripts/web1.fosiul.lan",
                owner => root,
                group => root,
                replace => true,
                force =>true
 
                }
 
		define module ( $ensure = 'present', $require = 'apache2' ) {
      		case $ensure {
         'present' : {
            exec { "/usr/sbin/a2enmod $name":
               unless => "/bin/readlink -e ${apache2_mods}-enabled/${name}.load",
               notify => Exec["force-reload-apache2"],
               require => Package[$require],
            }
         }
         'absent': {
            exec { "/usr/sbin/a2dismod $name":
               onlyif => "/bin/readlink -e ${apache2_mods}-enabled/${name}.load",
               notify => Exec["force-reload-apache2"],
               require => Package["apache2"],
            }
         }
         default: { err ( "Unknown ensure value: '$ensure'" ) }
      }
   }
 
	exec {
		"reload-apache2":
			command => "/etc/init.d/apache2 reload",
			refreshonly =>true,
 
		}
 
}

Ref : http://projects.puppetlabs.com/projects/1/wiki/Debian_Apache2_Recipe_Patterns

(b) Create related file under /etc/puppet/modules/apache/files/scripts

Leave a Reply

*