Custom file source for wsgi scripts

Adds possibility to:
- use custom file source for wsgi scripts
- use symlinks for wsgi scripts

Change-Id: I941bf8804982e9081812e076f7a736f413220047
Closes-bug: #1449553
This commit is contained in:
Aleksandr Didenko
2015-04-28 16:00:25 +03:00
parent 8a422583bf
commit 351ec64f67
2 changed files with 87 additions and 41 deletions

View File

@@ -73,13 +73,21 @@
# apache::vhost ssl parameters. # apache::vhost ssl parameters.
# Optional. Default to apache::vhost 'ssl_*' defaults. # Optional. Default to apache::vhost 'ssl_*' defaults.
# #
# [*priority*] # [*priority*]
# (optional) The priority for the vhost. # (optional) The priority for the vhost.
# Defaults to '10' # Defaults to '10'
# #
# [*threads*] # [*threads*]
# (optional) The number of threads for the vhost. # (optional) The number of threads for the vhost.
# Defaults to $::processorcount # Defaults to $::processorcount
#
# [*wsgi_script_ensure*]
# (optional) File ensure parameter for wsgi scripts.
# Defaults to 'file'.
#
# [*wsgi_script_source*]
# (optional) Wsgi script source.
# Defaults to undef.
# #
# == Dependencies # == Dependencies
# #
@@ -105,23 +113,25 @@
# Copyright 2013 eNovance <licensing@enovance.com> # Copyright 2013 eNovance <licensing@enovance.com>
# #
class keystone::wsgi::apache ( class keystone::wsgi::apache (
$servername = $::fqdn, $servername = $::fqdn,
$public_port = 5000, $public_port = 5000,
$admin_port = 35357, $admin_port = 35357,
$bind_host = undef, $bind_host = undef,
$public_path = '/', $public_path = '/',
$admin_path = '/', $admin_path = '/',
$ssl = true, $ssl = true,
$workers = 1, $workers = 1,
$ssl_cert = undef, $ssl_cert = undef,
$ssl_key = undef, $ssl_key = undef,
$ssl_chain = undef, $ssl_chain = undef,
$ssl_ca = undef, $ssl_ca = undef,
$ssl_crl_path = undef, $ssl_crl_path = undef,
$ssl_crl = undef, $ssl_crl = undef,
$ssl_certs_dir = undef, $ssl_certs_dir = undef,
$threads = $::processorcount, $threads = $::processorcount,
$priority = '10', $priority = '10',
$wsgi_script_ensure = 'file',
$wsgi_script_source = undef,
) { ) {
include ::keystone::params include ::keystone::params
@@ -159,28 +169,35 @@ class keystone::wsgi::apache (
require => Package['httpd'], require => Package['httpd'],
} }
file { 'keystone_wsgi_admin': $wsgi_files = {
ensure => file, 'keystone_wsgi_admin' => {
path => "${::keystone::params::keystone_wsgi_script_path}/admin", 'path' => "${::keystone::params::keystone_wsgi_script_path}/admin",
source => $::keystone::params::keystone_wsgi_script_source, },
owner => 'keystone', 'keystone_wsgi_main' => {
group => 'keystone', 'path' => "${::keystone::params::keystone_wsgi_script_path}/main",
mode => '0644', },
# source file provided by keystone package
require => [File[$::keystone::params::keystone_wsgi_script_path], Package['keystone']],
} }
file { 'keystone_wsgi_main': $wsgi_file_defaults = {
ensure => file, 'ensure' => $wsgi_script_ensure,
path => "${::keystone::params::keystone_wsgi_script_path}/main", 'owner' => 'keystone',
source => $::keystone::params::keystone_wsgi_script_source, 'group' => 'keystone',
owner => 'keystone', 'mode' => '0644',
group => 'keystone', 'require' => [File[$::keystone::params::keystone_wsgi_script_path], Package['keystone']],
mode => '0644',
# source file provided by keystone package
require => [File[$::keystone::params::keystone_wsgi_script_path], Package['keystone']],
} }
$wsgi_script_source_real = $wsgi_script_source ? {
default => $wsgi_script_source,
undef => $::keystone::params::keystone_wsgi_script_source,
}
case $wsgi_script_ensure {
'link': { $wsgi_file_source = { 'target' => $wsgi_script_source_real } }
default: { $wsgi_file_source = { 'source' => $wsgi_script_source_real } }
}
create_resources('file', $wsgi_files, merge($wsgi_file_defaults, $wsgi_file_source))
$wsgi_daemon_process_options_main = { $wsgi_daemon_process_options_main = {
user => 'keystone', user => 'keystone',
group => 'keystone', group => 'keystone',

View File

@@ -208,6 +208,35 @@ describe 'keystone::wsgi::apache' do
it_raises 'a Puppet::Error', /When using the same port for public & private endpoints, public_path and admin_path should be different\./ it_raises 'a Puppet::Error', /When using the same port for public & private endpoints, public_path and admin_path should be different\./
end end
describe 'when overriding parameters using symlink and custom file source' do
let :params do
{
:wsgi_script_ensure => 'link',
:wsgi_script_source => '/opt/keystone/httpd/keystone.py',
}
end
it { is_expected.to contain_file('keystone_wsgi_admin').with(
'ensure' => 'link',
'path' => "#{platform_parameters[:wsgi_script_path]}/admin",
'target' => '/opt/keystone/httpd/keystone.py',
'owner' => 'keystone',
'group' => 'keystone',
'mode' => '0644',
'require' => ["File[#{platform_parameters[:wsgi_script_path]}]", "Package[keystone]"]
)}
it { is_expected.to contain_file('keystone_wsgi_main').with(
'ensure' => 'link',
'path' => "#{platform_parameters[:wsgi_script_path]}/main",
'target' => '/opt/keystone/httpd/keystone.py',
'owner' => 'keystone',
'group' => 'keystone',
'mode' => '0644',
'require' => ["File[#{platform_parameters[:wsgi_script_path]}]", "Package[keystone]"]
)}
end
end end
context 'on RedHat platforms' do context 'on RedHat platforms' do