Added initial support for Debian and Ubuntu to apache module.
This commit is contained in:
parent
7075ad243d
commit
fa53a19798
3 changed files with 445 additions and 73 deletions
|
@ -34,6 +34,11 @@ class apache::common {
|
|||
}
|
||||
|
||||
package { "httpd":
|
||||
name => $operatingsystem ? {
|
||||
debian => "apache2",
|
||||
ubuntu => "apache2",
|
||||
default => "httpd",
|
||||
},
|
||||
ensure => installed,
|
||||
}
|
||||
|
||||
|
@ -73,15 +78,21 @@ class apache::common {
|
|||
class apache::server inherits apache::common {
|
||||
|
||||
if ! $httpd_user {
|
||||
$httpd_user = "apache"
|
||||
$httpd_user = $operatingsystem ? {
|
||||
debian => "www-data",
|
||||
ubuntu => "www-data",
|
||||
default => "apache",
|
||||
}
|
||||
}
|
||||
if ! $httpd_group {
|
||||
$httpd_group = "apache"
|
||||
$httpd_group = $operatingsystem ? {
|
||||
debian => "www-data",
|
||||
ubuntu => "www-data",
|
||||
default => "apache",
|
||||
}
|
||||
}
|
||||
|
||||
file { [ "/etc/httpd/conf.http.d",
|
||||
"/etc/httpd/site.http.d",
|
||||
"/srv/www/http",
|
||||
file { [ "/srv/www/http",
|
||||
"/srv/www/http/${fqdn}",
|
||||
"/srv/www/log/http",
|
||||
"/srv/www/log/http/${fqdn}", ]:
|
||||
|
@ -90,31 +101,66 @@ class apache::server inherits apache::common {
|
|||
owner => root,
|
||||
group => root,
|
||||
require => Package["httpd"],
|
||||
before => File["/etc/httpd/conf/httpd.conf"],
|
||||
before => $operatingsystem ? {
|
||||
debian => File["/etc/apache2/apache2.conf"],
|
||||
ubuntu => File["/etc/apache2/apache2.conf"],
|
||||
default => File["/etc/httpd/conf/httpd.conf"],
|
||||
},
|
||||
}
|
||||
|
||||
File["/etc/httpd/conf.http.d", "/etc/httpd/site.http.d"] {
|
||||
purge => true,
|
||||
force => true,
|
||||
recurse => true,
|
||||
source => "puppet:///custom/empty",
|
||||
}
|
||||
|
||||
file { "/etc/httpd/conf/httpd.conf":
|
||||
ensure => present,
|
||||
content => template("apache/httpd.conf.erb"),
|
||||
mode => 0644,
|
||||
owner => root,
|
||||
group => root,
|
||||
require => Package["httpd"],
|
||||
notify => Service["httpd"],
|
||||
}
|
||||
|
||||
service { "httpd":
|
||||
ensure => running,
|
||||
enable => true,
|
||||
require => [ Package["httpd"],
|
||||
File["/etc/httpd/conf/httpd.conf"], ],
|
||||
case $operatingsystem {
|
||||
debian,ubuntu: {
|
||||
file { "/etc/apache2/envvars":
|
||||
ensure => present,
|
||||
content => template("apache/apache2.envvars.erb"),
|
||||
mode => 0644,
|
||||
owner => root,
|
||||
group => root,
|
||||
require => Package["httpd"],
|
||||
notify => Service["apache2"],
|
||||
}
|
||||
file { "/etc/apache2/apache2.conf":
|
||||
ensure => present,
|
||||
content => template("apache/apache2.conf.erb"),
|
||||
mode => 0644,
|
||||
owner => root,
|
||||
group => root,
|
||||
require => File["/etc/apache2/envvars"],
|
||||
notify => Service["apache2"],
|
||||
}
|
||||
service { "apache2":
|
||||
ensure => running,
|
||||
enable => true,
|
||||
require => File["/etc/apache2/apache2.conf"],
|
||||
}
|
||||
}
|
||||
default: {
|
||||
file { [ "/etc/httpd/conf.http.d", "/etc/httpd/site.http.d" ]:
|
||||
ensure => directory,
|
||||
mode => 0644,
|
||||
owner => root,
|
||||
group => root,
|
||||
purge => true,
|
||||
force => true,
|
||||
recurse => true,
|
||||
source => "puppet:///custom/empty",
|
||||
require => Package["httpd"],
|
||||
before => File["/etc/httpd/conf/httpd.conf"],
|
||||
}
|
||||
file { "/etc/httpd/conf/httpd.conf":
|
||||
ensure => present,
|
||||
content => template("apache/httpd.conf.erb"),
|
||||
mode => 0644,
|
||||
owner => root,
|
||||
group => root,
|
||||
notify => Service["httpd"],
|
||||
}
|
||||
service { "httpd":
|
||||
ensure => running,
|
||||
enable => true,
|
||||
require => File["/etc/httpd/conf/httpd.conf"],
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -442,72 +488,143 @@ define apache::sslsite($root="", $config="", $ssl_cert="", $ssl_key="", $ssl_cha
|
|||
#
|
||||
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,
|
||||
case $operatingsystem {
|
||||
debian,ubuntu: {
|
||||
file { "/etc/apache2/conf.d/${name}":
|
||||
mode => 0644,
|
||||
owner => root,
|
||||
group => root,
|
||||
notify => Service["apache2"],
|
||||
require => Package["httpd"],
|
||||
}
|
||||
if $source {
|
||||
File["/etc/apache2/conf.d/${name}"] {
|
||||
source => $source,
|
||||
}
|
||||
}
|
||||
if $content {
|
||||
File["/etc/apache2/conf.d/${name}"] {
|
||||
content => $content,
|
||||
}
|
||||
}
|
||||
}
|
||||
if $content {
|
||||
File["/etc/httpd/conf.http.d/${name}"] {
|
||||
content => $content,
|
||||
default: {
|
||||
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 ! $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,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if defined(Service["httpsd"]) {
|
||||
file { "/etc/httpd/conf.https.d/${name}":
|
||||
ensure => $https ? {
|
||||
true => present,
|
||||
default => absent,
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
# Enable module on Debian/Ubuntu Apache.
|
||||
#
|
||||
# === Parameters
|
||||
#
|
||||
# $name:
|
||||
# Module name.
|
||||
# $source:
|
||||
# Source for optional module configuration.
|
||||
# $content:
|
||||
# Content for optional module configuration.
|
||||
# See also $source.
|
||||
# $require:
|
||||
# Dependencies for the module file.
|
||||
#
|
||||
define apache::a2enmod($source="", $content="") {
|
||||
|
||||
exec { "a2enmod-${name}":
|
||||
path => "/bin:/usr/bin:/sbin:/usr/sbin",
|
||||
command => "a2enmod ${name}",
|
||||
unless => "test -h /etc/apache2/mods-enabled/${name}.load",
|
||||
notify => Service["apache2"],
|
||||
require => Package["httpd"],
|
||||
}
|
||||
|
||||
if $source or $content {
|
||||
file { "/etc/apache2/mods-available/${name}.conf":
|
||||
mode => 0644,
|
||||
owner => root,
|
||||
group => root,
|
||||
notify => Service["httpsd"],
|
||||
notify => Service["apache2"],
|
||||
before => Exec["a2enmod-${name}"],
|
||||
}
|
||||
if $source {
|
||||
File["/etc/httpd/conf.https.d/${name}"] {
|
||||
File["/etc/apache2/mods-available/${name}.conf"] {
|
||||
source => $source,
|
||||
}
|
||||
}
|
||||
if $content {
|
||||
File["/etc/httpd/conf.https.d/${name}"] {
|
||||
File["/etc/apache2/mods-available/${name}.conf"] {
|
||||
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,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue