From 12ac1c01a240371c784e1ff01261913bae2e8b0d Mon Sep 17 00:00:00 2001 From: Ossi Salmi Date: Thu, 26 Nov 2009 18:38:05 +0200 Subject: [PATCH] Added apache::configfile for extra configuration deployment. --- apache/manifests/init.pp | 178 +++++++++++++++++++++++---------------- 1 file changed, 105 insertions(+), 73 deletions(-) diff --git a/apache/manifests/init.pp b/apache/manifests/init.pp index c1749e0..92f1382 100644 --- a/apache/manifests/init.pp +++ b/apache/manifests/init.pp @@ -311,6 +311,103 @@ define apache::sslsite($root="none", $config="none", } +# Install extra configuration file. +# +# === Parameters +# +# $name: +# Config file name. +# $source: +# Config file source. Defaults to /etc/httpd/conf.d/$name +# if neither $source nor $content is defined. +# $content: +# Config file content. See also $source. +# $require: +# Dependencies for the config file. +# $http: +# Set to false to disable config on http server. +# $https: +# Set to false to disable config on https server. +# +# === Sample usage +# +#apache::configfile { "auth_kerb.conf": +# content => template("apache/auth_kerb.conf.erb"), +# require => Package["mod_auth_kerb"], +# http => false, +#} +# +define apache::configfile($source="", $content="", $http=true, $https=true) { + + if defined(Service["httpd"]) { + file { "/etc/httpd/conf.http.d/${name}": + ensure => $http ? { + true => present, + default => absent, + }, + mode => 0644, + owner => root, + group => root, + notify => Service["httpd"], + } + if $source { + File["/etc/httpd/conf.http.d/${name}"] { + source => $source, + } + } + if $content { + File["/etc/httpd/conf.http.d/${name}"] { + content => $content, + } + } + if ! $source and ! $content { + File["/etc/httpd/conf.http.d/${name}"] { + source => "/etc/httpd/conf.d/${name}", + } + } + if $require { + File["/etc/httpd/conf.http.d/${name}"] { + require => $require, + } + } + } + + if defined(Service["httpsd"]) { + file { "/etc/httpd/conf.https.d/${name}": + ensure => $https ? { + true => present, + default => absent, + }, + mode => 0644, + owner => root, + group => root, + notify => Service["httpsd"], + } + if $source { + File["/etc/httpd/conf.https.d/${name}"] { + source => $source, + } + } + if $content { + File["/etc/httpd/conf.https.d/${name}"] { + content => $content, + } + } + if ! $source and ! $content { + File["/etc/httpd/conf.https.d/${name}"] { + source => "/etc/httpd/conf.d/${name}", + } + } + if $require { + File["/etc/httpd/conf.https.d/${name}"] { + require => $require, + } + } + } + +} + + # Install mod_auth_kerb. # class apache::mod::auth_kerb { @@ -320,33 +417,10 @@ class apache::mod::auth_kerb { require => Package["httpd"], } - file { "/etc/httpd/conf.d/auth_kerb.conf": - ensure => present, + apache::configfile { "auth_kerb.conf": content => template("apache/auth_kerb.conf.erb"), - mode => 0644, - owner => root, - group => root, require => Package["mod_auth_kerb"], - } - - if defined(Service["httpd"]) { - file { "/etc/httpd/conf.http.d/auth_kerb.conf": - ensure => link, - target => "/etc/httpd/conf.d/auth_kerb.conf", - require => Package["mod_auth_kerb"], - notify => Service["httpd"], - subscribe => File["/etc/httpd/conf.d/auth_kerb.conf"], - } - } - - if defined(Service["httpsd"]) { - file { "/etc/httpd/conf.https.d/auth_kerb.conf": - ensure => link, - target => "/etc/httpd/conf.d/auth_kerb.conf", - require => Package["mod_auth_kerb"], - notify => Service["httpsd"], - subscribe => File["/etc/httpd/conf.d/auth_kerb.conf"], - } + http => false, } } @@ -361,22 +435,8 @@ class apache::mod::perl { require => Package["httpd"], } - if defined(Service["httpd"]) { - file { "/etc/httpd/conf.http.d/perl.conf": - ensure => link, - target => "/etc/httpd/conf.d/perl.conf", - require => Package["mod_perl"], - notify => Service["httpd"], - } - } - - if defined(Service["httpsd"]) { - file { "/etc/httpd/conf.https.d/perl.conf": - ensure => link, - target => "/etc/httpd/conf.d/perl.conf", - require => Package["mod_perl"], - notify => Service["httpsd"], - } + apache::configfile { "perl.conf": + require => Package["mod_perl"], } } @@ -391,22 +451,8 @@ class apache::mod::php { require => Package["httpd"], } - if defined(Service["httpd"]) { - file { "/etc/httpd/conf.http.d/php.conf": - ensure => link, - target => "/etc/httpd/conf.d/php.conf", - require => Package["php"], - notify => Service["httpd"], - } - } - - if defined(Service["httpsd"]) { - file { "/etc/httpd/conf.https.d/php.conf": - ensure => link, - target => "/etc/httpd/conf.d/php.conf", - require => Package["php"], - notify => Service["httpsd"], - } + apache::configfile { "php.conf": + require => Package["php"], } } @@ -421,22 +467,8 @@ class apache::mod::python { require => Package["httpd"], } - if defined(Service["httpd"]) { - file { "/etc/httpd/conf.http.d/python.conf": - ensure => link, - target => "/etc/httpd/conf.d/python.conf", - require => Package["mod_python"], - notify => Service["httpd"], - } - } - - if defined(Service["httpsd"]) { - file { "/etc/httpd/conf.https.d/python.conf": - ensure => link, - target => "/etc/httpd/conf.d/python.conf", - require => Package["mod_python"], - notify => Service["httpsd"], - } + apache::configfile { "python.conf": + require => Package["mod_python"], } }