3 describe 'horizon::wsgi::apache' do
7 :servername => 'some.host.tld',
8 :wsgi_processes => '3',
15 "class { 'horizon': secret_key => 's3cr3t', configure_apache => false }"
19 File.expand_path(File.join(__FILE__, '..', '..', 'fixtures'))
23 { :concat_basedir => '/var/lib/puppet/concat',
24 :fqdn => 'some.host.tld'
28 shared_examples 'apache for horizon' do
30 context 'with default parameters' do
31 it 'configures apache' do
32 should contain_class('horizon::params')
33 should contain_class('apache')
34 should contain_class('apache::mod::wsgi')
35 should contain_service('httpd').with_name(platforms_params[:http_service])
36 should contain_file(platforms_params[:httpd_config_file])
37 should contain_package('horizon').with_ensure('present')
38 should contain_apache__vhost('horizon_vhost').with(
39 'servername' => 'some.host.tld',
40 'access_log_file' => 'horizon_access.log',
41 'error_log_file' => 'horizon_error.log',
43 'serveraliases' => '*',
44 'docroot' => '/var/www/',
46 'redirectmatch_status' => 'permanent',
47 'redirectmatch_regexp' => '^/$',
48 'redirectmatch_dest' => platforms_params[:root_url],
49 'wsgi_script_aliases' => { platforms_params[:root_url] => '/usr/share/openstack-dashboard/openstack_dashboard/wsgi/django.wsgi' },
50 'wsgi_process_group' => platforms_params[:wsgi_group],
51 'wsgi_daemon_process' => platforms_params[:wsgi_group],
52 'wsgi_daemon_process_options' => { 'processes' => params[:wsgi_processes], 'threads' => params[:wsgi_threads], 'user' => platforms_params[:unix_user], 'group' => platforms_params[:unix_group] }
57 context 'with overriden parameters' do
64 it 'configures apache' do
65 should contain_class('horizon::params')
66 should contain_class('apache')
67 should contain_class('apache::mod::wsgi')
68 should contain_service('httpd').with_name(platforms_params[:http_service])
69 should contain_file(platforms_params[:httpd_config_file])
70 should contain_package('horizon').with_ensure('present')
71 should contain_apache__vhost('horizon_vhost').with(
72 'servername' => 'some.host.tld',
73 'access_log_file' => 'horizon_access.log',
74 'error_log_file' => 'horizon_error.log',
75 'priority' => params[:priority],
76 'serveraliases' => '*',
77 'docroot' => '/var/www/',
79 'redirectmatch_status' => 'permanent',
80 'redirectmatch_regexp' => '^/$',
81 'redirectmatch_dest' => platforms_params[:root_url],
82 'wsgi_script_aliases' => { platforms_params[:root_url] => '/usr/share/openstack-dashboard/openstack_dashboard/wsgi/django.wsgi' },
83 'wsgi_process_group' => platforms_params[:wsgi_group],
84 'wsgi_daemon_process' => platforms_params[:wsgi_group],
85 'wsgi_daemon_process_options' => { 'processes' => params[:wsgi_processes], 'threads' => params[:wsgi_threads], 'user' => platforms_params[:unix_user], 'group' => platforms_params[:unix_group] }
90 context 'with ssl enabled' do
94 :ssl_redirect => true,
95 :horizon_cert => '/etc/pki/tls/certs/httpd.crt',
96 :horizon_key => '/etc/pki/tls/private/httpd.key',
97 :horizon_ca => '/etc/pki/tls/certs/ca.crt',
101 context 'with required parameters' do
102 it 'configures apache for SSL' do
103 should contain_class('apache::mod::ssl')
105 it { should contain_apache__vhost('horizon_ssl_vhost').with(
106 'servername' => 'some.host.tld',
107 'access_log_file' => 'horizon_ssl_access.log',
108 'error_log_file' => 'horizon_ssl_error.log',
110 'serveraliases' => '*',
111 'docroot' => '/var/www/',
113 'ssl_cert' => '/etc/pki/tls/certs/httpd.crt',
114 'ssl_key' => '/etc/pki/tls/private/httpd.key',
115 'ssl_ca' => '/etc/pki/tls/certs/ca.crt',
116 'redirectmatch_status' => 'permanent',
117 'redirectmatch_regexp' => '^/$',
118 'redirectmatch_dest' => platforms_params[:root_url],
119 'wsgi_process_group' => 'horizon-ssl',
120 'wsgi_daemon_process' => 'horizon-ssl',
121 'wsgi_script_aliases' => { platforms_params[:root_url] => '/usr/share/openstack-dashboard/openstack_dashboard/wsgi/django.wsgi' }
124 it { should contain_apache__vhost('horizon_vhost').with(
125 'servername' => 'some.host.tld',
126 'access_log_file' => 'horizon_access.log',
127 'error_log_file' => 'horizon_error.log',
129 'serveraliases' => '*',
130 'docroot' => '/var/www/',
132 'redirectmatch_status' => 'permanent',
133 'redirectmatch_regexp' => '(.*)',
134 'redirectmatch_dest' => 'https://some.host.tld',
135 'wsgi_process_group' => platforms_params[:wsgi_group],
136 'wsgi_daemon_process' => platforms_params[:wsgi_group],
137 'wsgi_script_aliases' => { platforms_params[:root_url] => '/usr/share/openstack-dashboard/openstack_dashboard/wsgi/django.wsgi' }
141 context 'without required parameters' do
143 context 'without horizon_ca parameter' do
144 before { params.delete(:horizon_ca) }
145 it_raises 'a Puppet::Error', /The horizon_ca parameter is required when listen_ssl is true/
148 context 'without horizon_cert parameter' do
149 before { params.delete(:horizon_cert) }
150 it_raises 'a Puppet::Error', /The horizon_cert parameter is required when listen_ssl is true/
153 context 'without horizon_key parameter' do
154 before { params.delete(:horizon_key) }
155 it_raises 'a Puppet::Error', /The horizon_key parameter is required when listen_ssl is true/
159 context 'with extra parameters' do
163 'add_listen' => false,
169 it 'configures apache' do
170 should contain_apache__vhost('horizon_vhost').with(
171 'add_listen' => false,
182 context 'on RedHat platforms' do
185 :osfamily => 'RedHat',
186 :operatingsystemrelease => '6.0'
190 let :platforms_params do
191 { :http_service => 'httpd',
192 :httpd_config_file => '/etc/httpd/conf.d/openstack-dashboard.conf',
193 :root_url => '/dashboard',
194 :apache_user => 'apache',
195 :apache_group => 'apache',
196 :wsgi_user => 'dashboard',
197 :wsgi_group => 'dashboard',
198 :unix_user => 'apache',
199 :unix_group => 'apache' }
202 it_behaves_like 'apache for horizon'
204 should contain_class('apache::mod::wsgi').with(:wsgi_socket_prefix => '/var/run/wsgi')
208 context 'on Debian platforms' do
211 :osfamily => 'Debian',
212 :operatingsystemrelease => '6.0'
216 let :platforms_params do
217 { :http_service => 'apache2',
218 :httpd_config_file => '/etc/apache2/conf-available/openstack-dashboard.conf',
219 :root_url => '/horizon',
220 :apache_user => 'www-data',
221 :apache_group => 'www-data',
222 :wsgi_user => 'horizon',
223 :wsgi_group => 'horizon',
224 :unix_user => 'horizon',
225 :unix_group => 'horizon' }
228 it_behaves_like 'apache for horizon'