Skip to content

Commit

Permalink
ensure default vhost config files are removed when false
Browse files Browse the repository at this point in the history
  • Loading branch information
jlambert121 committed Nov 4, 2013
1 parent 121958b commit 8493feb
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 19 deletions.
47 changes: 28 additions & 19 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
}

validate_bool($default_vhost)
validate_bool($default_ssl_vhost)
# true/false is sufficient for both ensure and enable
validate_bool($service_enable)
if $mpm_module {
Expand Down Expand Up @@ -247,26 +248,34 @@
if $mpm_module {
class { "apache::mod::${mpm_module}": }
}
if $default_vhost {
apache::vhost { 'default':
port => 80,
docroot => $docroot,
scriptalias => $scriptalias,
serveradmin => $serveradmin,
access_log_file => $access_log_file,
priority => '15',
}

$default_vhost_ensure = $default_vhost ? {
true => 'present',
false => 'absent'
}
if $default_ssl_vhost {
apache::vhost { 'default-ssl':
port => 443,
ssl => true,
docroot => $docroot,
scriptalias => $scriptalias,
serveradmin => $serveradmin,
access_log_file => "ssl_${access_log_file}",
priority => '15',
}
$default_ssl_vhost_ensure = $default_ssl_vhost ? {
true => 'present',
false => 'absent'
}

apache::vhost { 'default':
ensure => $default_vhost_ensure,
port => 80,
docroot => $docroot,
scriptalias => $scriptalias,
serveradmin => $serveradmin,
access_log_file => $access_log_file,
priority => '15',
}
apache::vhost { 'default-ssl':
ensure => $default_ssl_vhost_ensure,
port => 443,
ssl => true,
docroot => $docroot,
scriptalias => $scriptalias,
serveradmin => $serveradmin,
access_log_file => "ssl_${access_log_file}",
priority => '15',
}
}
}
27 changes: 27 additions & 0 deletions spec/classes/apache_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -356,4 +356,31 @@
end
end
end
context 'on all OSes' do
let :facts do
{
:osfamily => 'RedHat',
:operatingsystemrelease => '6',
:concat_basedir => '/dne',
}
end
context 'default vhost defaults' do
it { should contain_apache__vhost('default').with_ensure('present') }
it { should contain_apache__vhost('default-ssl').with_ensure('absent') }
end
context 'without default non-ssl vhost' do
let :params do {
:default_vhost => false
}
end
it { should contain_apache__vhost('default').with_ensure('absent') }
end
context 'with default ssl vhost' do
let :params do {
:default_ssl_vhost => true
}
end
it { should contain_apache__vhost('default').with_ensure('present') }
end
end
end

0 comments on commit 8493feb

Please sign in to comment.