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
This commit is contained in:
Colleen Murphy 2018-05-09 15:18:22 -07:00
parent 74aabb8bbb
commit 92b8a8c247
2 changed files with 14 additions and 19 deletions

View File

@ -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,

View File

@ -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}":