Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion manifests/vhost.pp
Original file line number Diff line number Diff line change
Expand Up @@ -2239,7 +2239,6 @@
$file_header_params = {
'comment' => $comment,
'nvh_addr_port' => $nvh_addr_port,
'mdomain' => $mdomain,
'servername' => $servername,
'define' => $define,
'protocols' => $protocols,
Expand All @@ -2257,6 +2256,19 @@
content => epp('apache/vhost/_file_header.epp', $file_header_params),
}

if $mdomain {
# Multiple VHosts can configure the same domain on different ports.
# Apache will fail if multile MDomain directive are set, so ensure we define it only for the first virutal host of each domain.
ensure_resource('file', "${servername}-mod_md", {
ensure => file,
path => "${apache::confd_dir}/mdomain-${servername}.conf",
mode => $apache::file_mode,
content => epp('apache/mdomain.epp', { mdomain => $mdomain, servername => $servername }),
require => File[$apache::confd_dir],
notify => Class['apache::service'],
})
}

if $docroot and $ensure == 'present' {
if $virtual_docroot {
include apache::mod::vhost_alias
Expand Down
4 changes: 2 additions & 2 deletions spec/defines/vhost_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -966,7 +966,7 @@
it { is_expected.to contain_class('apache::mod::md') }

it {
expect(subject).to contain_concat__fragment('rspec.example.com-apache-header').with(
expect(subject).to contain_file('example.com-mod_md').with(
content: %r{^MDomain example\.com example\.net auto$},
)
}
Expand Down Expand Up @@ -2166,7 +2166,7 @@
end

it {
expect(subject).to contain_concat__fragment('rspec.example.com-apache-header').with(
expect(subject).to contain_file('rspec.example.com-mod_md').with(
content: %r{^MDomain rspec.example.com$},
)
}
Expand Down
11 changes: 11 additions & 0 deletions templates/mdomain.epp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<%- |
Variant[Boolean, String[1]] $mdomain,
String[1] $servername,
| -%>
<%- if $mdomain { -%>
<%- if $mdomain =~ String { -%>
MDomain <%= $mdomain %>
<%-} else {-%>
MDomain <%= $servername %>
<%- } -%>
<% } -%>
9 changes: 0 additions & 9 deletions templates/vhost/_file_header.epp
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,6 @@
# Managed by Puppet
# ************************************
<%= [$comment].flatten.map |$c| { "# ${c}" }.join("\n") -%>
<%- if $mdomain { -%>

<%- if $mdomain =~ String { -%>

MDomain <%= $mdomain %>
<%-} else {-%>
MDomain <%= $servername %>
<%- } -%>
<% } -%>

<VirtualHost <%= [$nvh_addr_port].flatten().filter |$value| { $value }.join(' ') %>>
<% $define.each | $k, $v| { -%>
Expand Down
Loading