From 3850c5483746041ec1b65024810f035ed4926577 Mon Sep 17 00:00:00 2001 From: Monty Taylor Date: Sat, 4 Aug 2012 13:10:26 -0500 Subject: [PATCH] Align all web server usage on apache module. Change-Id: Idd712a8ee5ec81c6b88b7d3e2270dce4da254927 Reviewed-on: https://review.openstack.org/10838 Approved: Monty Taylor Reviewed-by: Monty Taylor Tested-by: Jenkins --- manifests/init.pp | 56 +++++++------------------------------ templates/mailman.vhost.erb | 6 ++-- 2 files changed, 13 insertions(+), 49 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 70a4522..c838d44 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -1,17 +1,19 @@ -class mailman($mailman_host='') { +class mailman($vhost_name=$fqdn) { + + include apache package { "mailman": ensure => installed, } - package { "apache2": - ensure => installed, + apache::vhost { $vhost_name: + port => 80, + docroot => "/var/www/", + priority => '50', + template => 'mailman/mailman.vhost.erb', } - - file { '/etc/apache2/mods-enabled/rewrite.load': - target => '/etc/apache2/mods-available/rewrite.load', - ensure => link, - require => Package['apache2'], + a2mod { 'rewrite': + ensure => present } file { "/var/www/index.html": @@ -34,37 +36,6 @@ class mailman($mailman_host='') { require => Package["mailman"] } - file { "/etc/apache2/sites-available/mailman": - content => template('mailman/mailman.vhost.erb'), - owner => 'root', - group => 'root', - ensure => 'present', - replace => 'true', - mode => 444, - require => Package["apache2"], - } - - file { "/etc/apache2/sites-enabled/mailman": - ensure => link, - target => '/etc/apache2/sites-available/mailman', - require => [ - File['/etc/apache2/sites-available/mailman'], - File['/etc/apache2/mods-enabled/rewrite.load'], - ], - } - - file { '/etc/apache2/sites-enabled/000-default': - require => File['/etc/apache2/sites-available/mailman'], - ensure => absent, - } - - exec { "gracefully restart apache": - subscribe => [ File["/etc/apache2/sites-available/mailman"]], - refreshonly => true, - path => "/bin:/usr/bin:/usr/sbin", - command => "apache2ctl graceful", - } - service { 'mailman': ensure => running, hasrestart => true, @@ -73,13 +44,6 @@ class mailman($mailman_host='') { require => Package["mailman"] } - service { 'apache2': - ensure => running, - hasrestart => true, - subscribe => File["/etc/apache2/sites-available/mailman"], - require => Package["apache2"] - } - file { '/etc/mailman/en': owner => 'root', group => 'list', diff --git a/templates/mailman.vhost.erb b/templates/mailman.vhost.erb index 16f613a..263a0b2 100644 --- a/templates/mailman.vhost.erb +++ b/templates/mailman.vhost.erb @@ -1,13 +1,13 @@ - ServerName <%= mailman_host %> + ServerName <%= scope.lookupvar("mailman::vhost_name") %> - ErrorLog ${APACHE_LOG_DIR}/mailman-error.log + ErrorLog ${APACHE_LOG_DIR}/<%= scope.lookupvar("mailman::vhost_name") %>-error.log # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn - CustomLog ${APACHE_LOG_DIR}/mailman-access.log combined + CustomLog ${APACHE_LOG_DIR}/<%= scope.lookupvar("mailman::vhost_name") %>-access.log combined DocumentRoot /var/www