From e9529a40917b0fcf0b1017ead583891180224c17 Mon Sep 17 00:00:00 2001 From: Colleen Murphy Date: Wed, 9 May 2018 15:18:22 -0700 Subject: [PATCH] Convert httpd::vhost to apache::vhost::custom For the most part, we can use the httpd::vhost defined type with templates defined in other modules as long as the variables in the templates are looked up with the scope object. This does not work at all if the httpd::vhost is declared within another defined type as opposed to a class, which means without this patch the mailman vhost template won't work with puppet 4. This patch converts the mailman::site resource to use the upstream apache::vhost::custom resource. The benefit of using the upstream resource is instead of passing the name of a template file which will be evaluated within httpd::vhost and not have access to any of the module's variables, we evaluate the template within the module and pass the content to the vhost resource. Change-Id: Iaa31189ace6140327af034fd8209211077d7c552 --- manifests/init.pp | 21 +++++++-------------- manifests/site.pp | 12 +++++++----- 2 files changed, 14 insertions(+), 19 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 961d8b2..4715e1c 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -5,7 +5,7 @@ class mailman( $multihost = false, ) { - include ::httpd + include ::apache package { 'mailman': ensure => installed, @@ -22,11 +22,11 @@ class mailman( require => Package['mailman'], } } else { - ::httpd::vhost { $vhost_name: - port => 80, - docroot => '/var/www/', + $port = 80 + $docroot = '/var/www/' + ::apache::vhost::custom { $vhost_name: priority => '50', - template => 'mailman/mailman.vhost.erb', + content => template('mailman/mailman.vhost.erb'), } file { '/etc/mailman/mm_cfg.py': ensure => present, @@ -46,15 +46,8 @@ class mailman( } } - httpd_mod { 'rewrite': - ensure => present, - before => Service['httpd'], - } - - httpd_mod { 'cgid': - ensure => present, - before => Service['httpd'], - } + include ::apache::mod::rewrite + include ::apache::mod::cgid file { '/var/www/index.html': ensure => present, diff --git a/manifests/site.pp b/manifests/site.pp index b79c99b..18e7a31 100644 --- a/manifests/site.pp +++ b/manifests/site.pp @@ -35,7 +35,7 @@ define mailman::site ( $default_url_host, $install_languages = ['en']) { - include ::httpd + include ::apache $root = "/srv/mailman/${name}" $dirs = [ @@ -98,11 +98,13 @@ define mailman::site ( # within the vhost template when evaluated as part of the vhost # define (which will override $name). $mailman_site_name = $name - ::httpd::vhost { $default_url_host: - port => 80, - docroot => '/var/www/', + $port = 80 + $docroot = '/var/www/' + $srvname = $default_url_host + $options = 'Indexes FollowSymLinks MultiViews' + ::apache::vhost::custom { $default_url_host: priority => '50', - template => 'mailman/mailman_multihost.vhost.erb', + content => template('mailman/mailman_multihost.vhost.erb'), } file { "/etc/init.d/mailman-${name}":