diff --git a/manifests/vhost.pp b/manifests/vhost.pp index 5d2ad8e5d..b772654cf 100644 --- a/manifests/vhost.pp +++ b/manifests/vhost.pp @@ -448,7 +448,7 @@ require => Package['httpd'], notify => Class['apache::service'], } - if $::osfamily == 'Debian' { + if $::apache::vhost_enable_dir { $vhost_enable_dir = $::apache::vhost_enable_dir $vhost_symlink_ensure = $ensure ? { present => link, diff --git a/spec/acceptance/vhost_spec.rb b/spec/acceptance/vhost_spec.rb index ce504cc3a..e003ab886 100644 --- a/spec/acceptance/vhost_spec.rb +++ b/spec/acceptance/vhost_spec.rb @@ -92,6 +92,39 @@ class { 'apache': } end end + context 'new vhost with enable symlink' do + it 'should configure an apache vhost and symlink it from $vhost_enable_dir' do + pp = <<-EOS + class { 'apache': + vhost_enable_dir => "#{$httpd_dir}/sites-enabled", + } + file { '#{$run_dir}': + ensure => 'directory', + recurse => true, + } + + apache::vhost { 'first.example.com': + port => '80', + docroot => '/var/www/first', + require => File['#{$run_dir}'], + } + EOS + apply_manifest(pp, :catch_failures => true) + end + + describe file("#{$vhost_dir}/25-first.example.com.conf") do + it { is_expected.to contain '' } + it { is_expected.to contain "ServerName first.example.com" } + end + describe file("#{$httpd_dir}/sites-enabled") do + it { is_expected.to contain_file("25-first.example.com.conf").with( + :ensure => 'link', + :path => "#{$httpd_dir}/sites-enabled/25-first.example.com.conf", + :target => "#{$vhost_dir}/25-first.example.com.conf" + ) } + end + end + context 'new proxy vhost on port 80' do it 'should configure an apache proxy vhost' do pp = <<-EOS