Use concat to manage local_settings.py
Manage local_settings.py content with concat::fragment. This adds the ability for anyone to add custom fragments to local_settings.py without having to override the template. Example on how to use concat::fragment: concat::fragment { 'local_settings.py:custom': target => $::horizon::params::config_file, content => 'HORIZON_CONFIG["customization_module"] = "my_project.overrides"', order => '90' } The use of puppetlabs-concat does not break backward compatibility for those establishing relationships with the file resource that used to be local_settings.py. puppetlabs-concat still declares a file resource matching the concat resource title when a concat resource is created. Closes-bug: #1383500 Change-Id: I97e747c967dddc04b62ff1d31440e42a26dcb3ff
This commit is contained in:
parent
1c31420b4a
commit
d63e437bdf
@ -258,12 +258,17 @@ class horizon(
|
||||
name => $::horizon::params::package_name,
|
||||
}
|
||||
|
||||
file { $::horizon::params::config_file:
|
||||
content => template($local_settings_template),
|
||||
concat { $::horizon::params::config_file:
|
||||
mode => '0644',
|
||||
require => Package['horizon'],
|
||||
}
|
||||
|
||||
concat::fragment { 'local_settings.py':
|
||||
target => $::horizon::params::config_file,
|
||||
content => template($local_settings_template),
|
||||
order => '50'
|
||||
}
|
||||
|
||||
package { 'python-lesscpy':
|
||||
ensure => $package_ensure,
|
||||
}
|
||||
@ -275,7 +280,7 @@ class horizon(
|
||||
}
|
||||
|
||||
if $compress_offline {
|
||||
File[$::horizon::params::config_file] ~> Exec['refresh_horizon_django_cache']
|
||||
Concat[$::horizon::params::config_file] ~> Exec['refresh_horizon_django_cache']
|
||||
}
|
||||
|
||||
if $configure_apache {
|
||||
|
@ -32,7 +32,7 @@ describe 'horizon' do
|
||||
:command => '/usr/share/openstack-dashboard/manage.py compress',
|
||||
:refreshonly => true,
|
||||
})}
|
||||
it { should contain_file(platforms_params[:config_file]).that_notifies('Exec[refresh_horizon_django_cache]') }
|
||||
it { should contain_concat(platforms_params[:config_file]).that_notifies('Exec[refresh_horizon_django_cache]') }
|
||||
|
||||
it 'configures apache' do
|
||||
should contain_class('horizon::wsgi::apache').with({
|
||||
@ -44,7 +44,7 @@ describe 'horizon' do
|
||||
end
|
||||
|
||||
it 'generates local_settings.py' do
|
||||
verify_contents(subject, platforms_params[:config_file], [
|
||||
verify_concat_fragment_contents(subject, 'local_settings.py', [
|
||||
'DEBUG = False',
|
||||
"ALLOWED_HOSTS = ['*', ]",
|
||||
"SECRET_KEY = 'elj1IWiLoWHgcyYxFVLj7cM5rGOOxWl0'",
|
||||
@ -66,7 +66,7 @@ describe 'horizon' do
|
||||
])
|
||||
|
||||
# From internals of verify_contents, get the contents to check for absence of a line
|
||||
content = subject.resource('file', platforms_params[:config_file]).send(:parameters)[:content]
|
||||
content = subject.resource('concat::fragment', 'local_settings.py').send(:parameters)[:content]
|
||||
|
||||
# With default options, should _not_ have a line to configure SESSION_ENGINE
|
||||
content.should_not match(/^SESSION_ENGINE/)
|
||||
@ -96,7 +96,7 @@ describe 'horizon' do
|
||||
end
|
||||
|
||||
it 'generates local_settings.py' do
|
||||
verify_contents(subject, platforms_params[:config_file], [
|
||||
verify_concat_fragment_contents(subject, 'local_settings.py', [
|
||||
'DEBUG = True',
|
||||
"ALLOWED_HOSTS = ['*', ]",
|
||||
'CSRF_COOKIE_SECURE = True',
|
||||
@ -136,7 +136,7 @@ describe 'horizon' do
|
||||
end
|
||||
|
||||
it 'generates local_settings.py' do
|
||||
verify_contents(subject, platforms_params[:config_file], [
|
||||
verify_concat_fragment_contents(subject, 'local_settings.py', [
|
||||
" 'LOCATION': [ '10.0.0.1:11211','10.0.0.2:11211', ],",
|
||||
])
|
||||
end
|
||||
@ -202,7 +202,7 @@ describe 'horizon' do
|
||||
end
|
||||
|
||||
it 'AVAILABLE_REGIONS is configured' do
|
||||
verify_contents(subject, platforms_params[:config_file], [
|
||||
verify_concat_fragment_contents(subject, 'local_settings.py', [
|
||||
"AVAILABLE_REGIONS = [",
|
||||
" ('http://region-1.example.com:5000/v2.0', 'Region-1'),",
|
||||
" ('http://region-2.example.com:5000/v2.0', 'Region-2'),",
|
||||
@ -224,7 +224,7 @@ describe 'horizon' do
|
||||
end
|
||||
|
||||
it 'POLICY_FILES_PATH and POLICY_FILES are configured' do
|
||||
verify_contents(subject, platforms_params[:config_file], [
|
||||
verify_concat_fragment_contents(subject, 'local_settings.py', [
|
||||
"POLICY_FILES_PATH = '/opt/openstack-dashboard'",
|
||||
"POLICY_FILES = {",
|
||||
" 'identity': 'keystone_policy.json',",
|
||||
@ -245,7 +245,7 @@ describe 'horizon' do
|
||||
end
|
||||
|
||||
it 'uses the custom local_settings.py template' do
|
||||
verify_contents(subject, platforms_params[:config_file], [
|
||||
verify_concat_fragment_contents(subject, 'local_settings.py', [
|
||||
'# Custom local_settings.py',
|
||||
'DEBUG = True',
|
||||
"HORIZON_CONFIG = {",
|
||||
|
@ -5,3 +5,8 @@ RSpec.configure do |c|
|
||||
c.alias_it_should_behave_like_to :it_configures, 'configures'
|
||||
c.alias_it_should_behave_like_to :it_raises, 'raises'
|
||||
end
|
||||
|
||||
def verify_concat_fragment_contents(subject, title, expected_lines)
|
||||
content = subject.resource('concat::fragment', title).send(:parameters)[:content]
|
||||
(content.split("\n") & expected_lines).should == expected_lines
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user