diff options
author | mh <mh@immerda.ch> | 2008-11-01 11:16:54 +0000 |
---|---|---|
committer | mh <mh@immerda.ch> | 2008-11-01 11:16:54 +0000 |
commit | 0e75ef0a2b30bfdfc74a4c18e0ea3f4b86b34e25 (patch) | |
tree | 5170dc10e27cb1675b0ad335c08ce08414904823 /manifests | |
parent | 22bdcda8946555836ffada43451f8daba465720f (diff) |
merged with puzzle
Diffstat (limited to 'manifests')
-rw-r--r-- | manifests/defines.pp | 139 | ||||
-rw-r--r-- | manifests/init.pp | 218 | ||||
-rw-r--r-- | manifests/itk.pp | 2 | ||||
-rw-r--r-- | manifests/php.pp | 5 | ||||
-rw-r--r-- | manifests/ssl.pp | 33 | ||||
-rw-r--r-- | manifests/status.pp | 21 |
6 files changed, 228 insertions, 190 deletions
diff --git a/manifests/defines.pp b/manifests/defines.pp new file mode 100644 index 0000000..d6d1ec0 --- /dev/null +++ b/manifests/defines.pp @@ -0,0 +1,139 @@ +# manifests/defines.pp + +define apache::config::file( + $source = '', + $destination = '' +){ + $real_source = $source ? { + # get a whole bunch of possible sources if there is no specific source for that config-file + '' => [ + "puppet://$server/files/apache/conf.d/${fqdn}/${name}", + "puppet://$server/files/apache/conf.d/${name}", + "puppet://$server/apache/conf.d/${operatingsystem}.${lsbdistcodename}/${name}", + "puppet://$server/apache/conf.d/${operatingsystem}/${name}", + "puppet://$server/apache/conf.d/${name}" + ], + default => "puppet://$server/$source", + } + $real_destination = $destination ? { + '' => $operatingsystem ? { + centos => "$apache::centos::config_dir/conf.d/${name}", + gentoo => "$apache::gentoo::config_dir/${name}", + debian => "$apache::debian::config_dir/conf.d/${name}", + ubuntu => "$apache::ubuntu::config_dir/conf.d/${name}", + openbsd => "$apache::openbsd::config_dir/conf.d/${name}", + default => "/etc/apache2/${name}", + }, + default => $destination + } + file{"apache_${name}": + path => $real_destination, + source => $real_source, + require => Package[apache], + notify => Service[apache], + owner => root, group => 0, mode => 0644; + } +} + +define apache::vhost::file( + $source = 'absent', + $destination = 'absent', + $content = 'absent' +){ + $vhosts_dir = $operatingsystem ? { + centos => "$apache::centos::config_dir/vhosts.d/", + gentoo => "$apache::gentoo::config_dir/vhosts.d/", + debian => "$apache::debian::config_dir/vhosts.d/", + ubuntu => "$apache::ubuntu::config_dir/vhosts.d/", + openbsd => "$apache::openbsd::config_dir/vhosts.d/", + default => '/etc/apache2/vhosts.d/', + } + $real_destination = $destination ? { + 'absent' => "${vhosts_dir}/${name}.conf", + default => $destination, + } + file{"${name}.conf": + path => $real_destination, + require => [ File[vhosts_dir], Package[apache] ], + notify => Service[apache], + owner => root, group => 0, mode => 0644; + } + case $content { + 'absent': { + $real_source = $source ? { + 'absent' => [ + "puppet://$server/files/apache/vhosts.d/${fqdn}/${name}.conf", + "puppet://$server/files/apache/vhosts.d/${name}.conf", + "puppet://$server/apache/vhosts.d/${name}.conf", + "puppet://$server/apache/vhosts.d/${operatingsystem}.${lsbdistcodename}/${name}.conf", + "puppet://$server/apache/vhosts.d/${operatingsystem}/${name}.conf", + "puppet://$server/apache/vhosts.d/${name}.conf" + ], + default => "puppet://$server/$source", + } + File["${name}.conf"]{ + source => $real_source, + } + } + default: { + File["${name}.conf"]{ + content => $content, + } + } + } +} + +define apache::centos::module( + $source = '', + $destination = '' +){ + $modules_dir = "$apache::centos::config_dir/modules.d/" + $real_destination = $destination ? { + '' => "${modules_dir}/${name}.so", + default => $destination, + } + $real_source = $source ? { + '' => [ + "puppet://$server/files/apache/modules.d/${fqdn}/${name}.so", + "puppet://$server/files/apache/modules.d/${name}.so", + "puppet://$server/apache/modules.d/${operatingsystem}/${name}.so", + "puppet://$server/apache/modules.d/${name}.so" + ], + default => "puppet://$server/$source", + } + file{"modules_${name}.conf": + path => $real_destination, + source => $real_source, + require => [ File[modules_dir], Package[apache] ], + notify => Service[apache], + owner => root, group => 0, mode => 0755; + } +} + + +define apache::gentoo::module( + $source = '', + $destination = '' +){ + $modules_dir = "$apache::gentoo::config_dir/modules.d/" + $real_destination = $destination ? { + '' => "${modules_dir}/${name}.conf", + default => $destination, + } + $real_source = $source ? { + '' => [ + "puppet://$server/files/apache/modules.d/${fqdn}/${name}.conf", + "puppet://$server/files/apache/modules.d/${name}.conf", + "puppet://$server/apache/modules.d/${operatingsystem}/${name}.conf", + "puppet://$server/apache/modules.d/${name}.conf" + ], + default => "puppet://$server/$source", + } + file{"modules_${name}.conf": + path => $real_destination, + source => $real_source, + require => [ File[modules_dir], Package[apache] ], + notify => Service[apache], + owner => root, group => 0, mode => 0644; + } +} diff --git a/manifests/init.pp b/manifests/init.pp index cf8dce0..cd6d468 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -12,6 +12,8 @@ # the Free Software Foundation. # +import "defines.pp" + class apache { case $operatingsystem { centos: { include apache::centos } @@ -20,7 +22,6 @@ class apache { ubuntu: { include apache::ubuntu } default: { include apache::base } } - if $selinux { include apache::selinux } @@ -36,19 +37,16 @@ class apache::base { require => Package[apache], owner => root, group => 0, mode => 0755; } - file{'modules_dir': path => '/etc/apache2/modules.d/', ensure => directory, require => Package[apache], owner => root, group => 0, mode => 0755; } - package { 'apache': name => 'apache', ensure => present, } - service { apache: name => 'apache2', enable => true, @@ -64,22 +62,18 @@ class apache::base { } } -### distro specific stuff -class apache::centos inherits apache::base{ + +### distribution specific classes + +### centos +class apache::centos inherits apache::base { $config_dir = '/etc/httpd/' + Package[apache]{ name => 'httpd', } Service[apache]{ - name => 'httpd' - } - package { 'mod_ssl': - name => 'mod_ssl', - ensure => present, - require => Package[apache], - } - File[default_apache_index]{ - path => '/var/www/html/index.html', + name => 'httpd', } File[vhosts_dir]{ path => "$config_dir/vhosts.d/", @@ -87,39 +81,24 @@ class apache::centos inherits apache::base{ File[modules_dir]{ path => "$config_dir/modules.d/", } - - file{"${config_dir}/conf.d/ZZZ_vhosts.conf": - source => "puppet://$server/apache/centos/vhosts.conf", - require => Package['apache'], - owner => root, group => 0, mode => 0644; - } - file{"${config_dir}/conf/httpd.conf": - source => [ "puppet://$server/files/apache/centos/${fqdn}/httpd.conf", - "puppet://$server/files/apache/centos/httpd.conf", - "puppet://$server/apache/centos/${operatingsystemrelease}/httpd.conf", - "puppet://$server/apache/centos/httpd.conf" ], - require => Package['apache'], - owner => root, group => 0, mode => 0644; - } - file{"${config_dir}/conf.d/ssl.conf": - source => [ "puppet://$server/files/apache/centos/${fqdn}/ssl.conf", - "puppet://$server/files/apache/centos/ssl.conf", - "puppet://$server/apache/centos/${operatingsystemrelease}/ssl.conf", - "puppet://$server/apache/centos/ssl.conf" ], - require => Package['apache'], - owner => root, group => 0, mode => 0644; + File[default_apache_index]{ + path => '/var/www/html/index.html', } - apache::vhost::file { '00_default_centos_vhost': } - apache::config::file{ 'ssl_defaults.inc': } apache::config::file{ 'welcome.conf': } + apache::config::file{ 'defaults.inc': } + apache::config::file{ 'vhosts.conf': } + apache::vhost::file { '0-default': } } +### gentoo class apache::gentoo inherits apache::base { $config_dir = '/etc/apache2/' # needs module gentoo - gentoo::etcconfd { apache2: require => "Package[apache]", notify => "Service[apache]"} - + gentoo::etcconfd { + apache2: require => "Package[apache]", + notify => "Service[apache]" + } Package[apache]{ category => 'www-servers', } @@ -129,15 +108,14 @@ class apache::gentoo inherits apache::base { File[modules_dir]{ path => "$config_dir/modules.d/", } - apache::vhost::file { '00_default_ssl_vhost': } + apache::gentoo::module { '00_default_settings': } + apache::gentoo::module { '00_error_documents': } + apache::vhost::file { '00_default_vhost': } apache::config::file { 'default_vhost.include': source => "apache/vhosts.d/default_vhost.include", destination => "$config_dir/vhosts.d/default_vhost.include", } - - apache::module::file { '00_default_settings': } - apache::module::file { '00_error_documents': } # set the default for the ServerName file{"${config_dir}/modules.d/00_default_settings_ServerName.conf": @@ -147,19 +125,26 @@ class apache::gentoo inherits apache::base { } } +### debian class apache::debian inherits apache::base { $config_dir = '/etc/apache2/' + file {"$vhosts_dir": ensure => '/etc/apache2/sites-enabled/', } File[default_apache_index] { path => '/var/www/index.html', } + } -# ubuntu is similar to debian therefor inheritng from there + +### ubuntu: similar to debian therefor inheritng from there class apache::ubuntu inherits apache::debian {} + +### openbsd class apache::openbsd inherits apache::base { $config_dir = '/var/www/conf/' + File[vhosts_dir]{ path => "$config_dir/vhosts.d/", } @@ -170,146 +155,3 @@ class apache::openbsd inherits apache::base { path => '/var/www/htdocs/index.html', } } - -### config things -define apache::vhost::file( - $source = 'absent', - $destination = 'absent', - $content = 'absent' -){ - $vhosts_dir = $operatingsystem ? { - centos => "$apache::centos::config_dir/vhosts.d/", - gentoo => "$apache::gentoo::config_dir/vhosts.d/", - debian => "$apache::debian::config_dir/vhosts.d/", - ubuntu => "$apache::ubuntu::config_dir/vhosts.d/", - openbsd => "$apache::openbsd::config_dir/vhosts.d/", - default => '/etc/apache2/vhosts.d/', - } - - $real_destination = $destination ? { - 'absent' => "${vhosts_dir}/${name}.conf", - default => $destination, - } - file{"vhost_${name}.conf": - path => $real_destination, - require => [ File[vhosts_dir], Package[apache] ], - notify => Service[apache], - owner => root, group => 0, mode => 0644; - } - case $content { - 'absent': { - $real_source = $source ? { - 'absent' => [ - "puppet://$server/files/apache/vhosts.d/${fqdn}/${name}.conf", - "puppet://$server/files/apache/vhosts.d/${name}.conf", - "puppet://$server/apache/vhosts.d/${name}.conf" - ], - default => "puppet://$server/$source", - } - File["vhost_${name}.conf"]{ - source => $real_source, - } - } - default: { - File["vhost_${name}.conf"]{ - content => $content, - } - } - } -} - -define apache::module::file( - $source = '', - $destination = '' -){ - $modules_dir = $operatingsystem ? { - centos => "$apache::centos::config_dir/modules.d/", - gentoo => "$apache::gentoo::config_dir/modules.d/", - debian => "$apache::debian::config_dir/modules.d/", - ubuntu => "$apache::ubuntu::config_dir/modules.d/", - openbsd => "$apache::openbsd::config_dir/modules.d/", - default => '/etc/apache2/modules.d/', - } - - $real_destination = $destination ? { - '' => "${modules_dir}/${name}.conf", - default => $destination, - } - - $real_source = $source ? { - '' => [ - "puppet://$server/files/apache/modules.d/${fqdn}/${name}.conf", - "puppet://$server/files/apache/modules.d/${name}.conf", - "puppet://$server/apache/modules.d/${operatingsystem}/${name}.conf", - "puppet://$server/apache/modules.d/${name}.conf" - ], - default => "puppet://$server/$source", - } - - file{"modules_${name}.conf": - path => $real_destination, - source => $real_source, - require => [ File[modules_dir], Package[apache] ], - notify => Service[apache], - owner => root, group => 0, mode => 0644; - } -} - -define apache::config::file( - $source = '', - $destination = '' -){ - $real_source = $source ? { - # get a whole bunch of possible sources if there is no specific source for that config-file - '' => [ - "puppet://$server/files/apache/conf/${fqdn}/${name}", - "puppet://$server/files/apache/conf/${name}", - "puppet://$server/apache/conf/${name}.${operatingsystem}.${lsbdistcodename}", - "puppet://$server/apache/conf/${name}.${operatingsystem}", - "puppet://$server/apache/conf/${name}.Default", - "puppet://$server/apache/conf/${name}" - ], - default => "puppet://$server/$source", - } - - $real_destination = $destination ? { - '' => $operatingsystem ? { - centos => "$apache::centos::config_dir/conf.d/${name}", - gentoo => "$apache::gentoo::config_dir/${name}", - debian => "$apache::debian::config_dir/conf.d/${name}", - ubuntu => "$apache::ubuntu::config_dir/conf.d/${name}", - openbsd => "$apache::openbsd::config_dir/conf.d/${name}", - default => "/etc/apache2/${name}", - }, - default => $destination - } - - file{"apache_${name}": - path => $real_destination, - source => $real_source, - require => Package[apache], - notify => Service[apache], - owner => root, group => 0, mode => 0644; - } -} - -class apache::php inherits apache { - include php -} - -class apache::status { - case $operatingsystem { - centos: { include apache::status::centos } - } - if $use_munin { - include munin::plugins::apache - } -} - -class apache::status::centos { - file{"/etc/httpd/conf.d/status.conf": - source => "puppet://$server/apache/centos/status.conf", - require => Package['apache'], - owner => root, group => 0, mode => 0644; - } -} diff --git a/manifests/itk.pp b/manifests/itk.pp index 7dfddeb..517da7b 100644 --- a/manifests/itk.pp +++ b/manifests/itk.pp @@ -8,7 +8,6 @@ class apache::itk inherits apache { default: { include apache::base::itk } } } - class apache::base::itk inherits apache::base { Package['apache'] { name => 'apache2-itk', @@ -20,7 +19,6 @@ class apache::centos::itk inherits apache::centos { Package['apache']{ name => 'httpd-itk', } - Package['mod_ssl']{ name => 'mod_ssl-itk', } diff --git a/manifests/php.pp b/manifests/php.pp new file mode 100644 index 0000000..c224731 --- /dev/null +++ b/manifests/php.pp @@ -0,0 +1,5 @@ +# manifests/php.pp + +class apache::php inherits apache { + include php +} diff --git a/manifests/ssl.pp b/manifests/ssl.pp new file mode 100644 index 0000000..7106907 --- /dev/null +++ b/manifests/ssl.pp @@ -0,0 +1,33 @@ +# manifests/ssl.pp + +class apache::ssl inherits apache { + case $operatingsystem { + centos: { include apache::ssl::centos } + gentoo: { include apache::ssl::gentoo } + defaults: { include apache::ssl::base } + } +} + +class apache::ssl::base {} + + +### distribution specific classes + +### centos +class apache::ssl::centos inherits apache::ssl::base { + package { 'mod_ssl': + name => 'mod_ssl', + ensure => present, + require => Package[apache], + } + apache::config::file{ 'ssl.conf': } + apache::config::file{ 'ssl_defaults.inc': } + apache::vhost::file{ '0-default_ssl.conf': } +} + +### gentoo +class apache::ssl::gentoo inherits apache::ssl::base { + apache::module::file { '00_default_settings': } + apache::module::file { '00_error_documents': } + apache::vhost::file { '00_default_ssl_vhost': } +} diff --git a/manifests/status.pp b/manifests/status.pp new file mode 100644 index 0000000..0048a64 --- /dev/null +++ b/manifests/status.pp @@ -0,0 +1,21 @@ +# manifests/status.pp + +class apache::status inherits apache { + case $operatingsystem { + centos: { include apache::status::centos } + defaults: { include apache::status::base } + } + if $use_munin { + include munin::plugins::apache + } +} + +class apache::status::base {} + + +### distribution specific classes + +### centos +class apache::status::centos { + apache::config::file{ 'status.conf': } +} |