Added apache::configfile for extra configuration deployment.

This commit is contained in:
Ossi Salmi 2009-11-26 18:38:05 +02:00 committed by Timo Mkinen
parent 0d5d809519
commit 12ac1c01a2

View file

@ -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"],
}
}