Skip to content

Commit c00cdd4

Browse files
author
Martin Mörner
committed
Symlinks on all distros
- Create symlinks on all distros (not just Debian) when a separate $vhost_enable_dir is used. Without this a different $vhost_enable_dir as conf.d on centos does not create symlinks to enable vhosts. - added a $vhost_enable_dir acceptance test
1 parent 0244c7a commit c00cdd4

2 files changed

Lines changed: 34 additions & 1 deletion

File tree

manifests/vhost.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@
440440
require => Package['httpd'],
441441
notify => Class['apache::service'],
442442
}
443-
if $::osfamily == 'Debian' {
443+
if $::apache::vhost_enable_dir {
444444
$vhost_enable_dir = $::apache::vhost_enable_dir
445445
$vhost_symlink_ensure = $ensure ? {
446446
present => link,

spec/acceptance/vhost_spec.rb

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,39 @@ class { 'apache': }
9292
end
9393
end
9494

95+
context 'new vhost with enable symlink' do
96+
it 'should configure an apache vhost and symlink it from $vhost_enable_dir' do
97+
pp = <<-EOS
98+
class { 'apache':
99+
vhost_enable_dir => "#{$httpd_dir}/sites-enabled",
100+
}
101+
file { '#{$run_dir}':
102+
ensure => 'directory',
103+
recurse => true,
104+
}
105+
106+
apache::vhost { 'first.example.com':
107+
port => '80',
108+
docroot => '/var/www/first',
109+
require => File['#{$run_dir}'],
110+
}
111+
EOS
112+
apply_manifest(pp, :catch_failures => true)
113+
end
114+
115+
describe file("#{$vhost_dir}/25-first.example.com.conf") do
116+
it { is_expected.to contain '<VirtualHost \*:80>' }
117+
it { is_expected.to contain "ServerName first.example.com" }
118+
end
119+
describe file("#{$httpd_dir}/sites-enabled") do
120+
it { is_expected.to contain_file("25-first.example.com.conf").with(
121+
:ensure => 'link',
122+
:path => "#{$httpd_dir}/sites-enabled/25-first.example.com.conf",
123+
:target => "#{$vhost_dir}/25-first.example.com.conf"
124+
) }
125+
end
126+
end
127+
95128
context 'new proxy vhost on port 80' do
96129
it 'should configure an apache proxy vhost' do
97130
pp = <<-EOS

0 commit comments

Comments
 (0)