Manage apache vhost

This commit is contained in:
Tom De Vylder 2015-02-20 15:50:42 +01:00
parent dca2b08678
commit fcceebcfcf
4 changed files with 83 additions and 9 deletions

View file

@ -1,7 +1,8 @@
fixtures:
repositories:
stdlib: 'git://github.com/puppetlabs/puppetlabs-stdlib.git'
vcsrepo: 'git://github.com/puppetlabs/puppetlabs-vcsrepo.git'
apache: 'git://github.com/puppetlabs/puppetlabs-apache.git'
stdlib: 'git://github.com/puppetlabs/puppetlabs-stdlib.git'
vcsrepo: 'git://github.com/puppetlabs/puppetlabs-vcsrepo.git'
symlinks:
icingaweb2: "#{source_dir}"

View file

@ -54,5 +54,11 @@ class icingaweb2::config {
ensure => directory,
mode => $::icingaweb2::config_dir_mode;
}
if $::icingaweb2::manage_apache_vhost {
::apache::custom_config { 'icingaweb2':
content => template('icingaweb2/apache2.conf.erb'),
}
}
}

View file

@ -258,13 +258,13 @@ describe 'icingaweb2', :type => :class do
context 'manage_apache_vhost => true' do
let (:params) { { :manage_apache_vhost => true } }
pending
it { should contain_apache__custom_config('icingaweb2') }
end
context 'manage_apache_vhost => false' do
let (:params) { { :manage_apache_vhost => false } }
pending
it { should_not contain_apache__custom_config('icingaweb2') }
end
end
@ -312,12 +312,34 @@ describe 'icingaweb2', :type => :class do
end
describe 'with parameter: web_root' do
let (:params) { { :web_root => '/web/root' } }
context 'default' do
let (:params) { { :web_root => '/web/root' } }
it { should contain_file('/web/root').with(
'ensure' => 'directory'
)
}
it { should contain_file('/web/root').with(
'ensure' => 'directory'
)
}
end
context 'manage_apache_vhost => true' do
let (:params) {
{
:manage_apache_vhost => true,
:web_root => '/web/root'
}
}
it { should contain_file('/web/root').with(
'ensure' => 'directory'
)
}
it { should contain_apache__custom_config('icingaweb2').with(
'content' => /Alias.*\/web\/root/,
'content' => /<Directory.*\/web\/root/
)
}
end
end
end

View file

@ -0,0 +1,45 @@
###################################################################
# #
# WARNING: This config file is automatically generated by Puppet. #
# ANY MANUAL CHANGES TO IT WILL GET OVERWRITTEN! #
# #
###################################################################
Alias /icingaweb2 "<%= @web_root %>/public"
<Directory "<%= @web_root %>/public">
Options SymLinksIfOwnerMatch
AllowOverride None
<IfModule mod_authz_core.c>
# Apache 2.4
<RequireAll>
Require all granted
</RequireAll>
</IfModule>
<IfModule !mod_authz_core.c>
# Apache 2.2
Order allow,deny
Allow from all
</IfModule>
SetEnv ICINGAWEB_CONFIGDIR "<%= @config_dir %>"
EnableSendfile Off
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /icingaweb2/
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
</IfModule>
<IfModule !mod_rewrite.c>
DirectoryIndex error_norewrite.html
ErrorDocument 404 /error_norewrite.html
</IfModule>
</Directory>