Support purging local_settings.d

In Debian, some files are installed into local_settings.d by their
packages and these conflict with the options added to local_settings.
This introduces an option to purge the directory.

Change-Id: I7e074f78b15ab22d86d6a6a10f573cfc4052023a
This commit is contained in:
Takashi Kajinami
2023-11-14 10:30:04 +09:00
parent cfe50237b6
commit e1e446e689
3 changed files with 32 additions and 4 deletions

View File

@@ -8,6 +8,13 @@
# (required) Secret key. This is used by Django to provide cryptographic
# signing, and should be set to a unique, unpredictable value.
#
# [*package_ensure*]
# (optional) Package ensure state. Defaults to 'present'.
#
# [*purge_conf_d_dir*]
# (optional) Purge files in the local_settings.d directory
# Defaults to false
#
# [*servername*]
# (optional) FQDN used for the Server Name directives
# Defaults to facts['networking']['fqdn'].
@@ -24,9 +31,6 @@
# in vhost.conf.
# Defaults to facts['networking']['fqdn'].
#
# [*package_ensure*]
# (optional) Package ensure state. Defaults to 'present'.
#
# [*cache_backend*]
# (optional) Horizon cache backend.
# Defaults: 'django.core.cache.backends.locmem.LocMemCache'
@@ -534,6 +538,7 @@
class horizon(
$secret_key,
$package_ensure = 'present',
Boolean $purge_conf_d_dir = false,
$cache_backend = 'django.core.cache.backends.locmem.LocMemCache',
$cache_options = undef,
$cache_timeout = undef,
@@ -723,6 +728,8 @@ class horizon(
file { $::horizon::params::conf_d_dir:
ensure => 'directory',
mode => '0755',
purge => $purge_conf_d_dir,
recurse => $purge_conf_d_dir,
owner => $::horizon::params::wsgi_user,
group => $::horizon::params::wsgi_group,
require => Anchor['horizon::config::begin'],

View File

@@ -0,0 +1,4 @@
---
features:
- |
The new ``horizon::purge_conf_d_dir`` parameter has been added.

View File

@@ -67,6 +67,15 @@ describe 'horizon' do
expect(content).not_to match(/^SESSION_ENGINE/)
end
it { is_expected.to contain_file(platforms_params[:conf_d_dir]).with(
:ensure => 'directory',
:mode => '0755',
:purge => false,
:recurse => false,
:owner => platforms_params[:wsgi_user],
:group => platforms_params[:wsgi_group],
) }
it 'creates a key file' do
is_expected.to contain_file(platforms_params[:secret_key_file]).with(
:mode => '0600',
@@ -82,6 +91,7 @@ describe 'horizon' do
context 'with overridden parameters' do
before do
params.merge!({
:purge_conf_d_dir => true,
:cache_backend => 'django.core.cache.backends.memcached.MemcachedCache',
:cache_timeout => 300,
:cache_options => {'SOCKET_TIMEOUT' => 1,'SERVER_RETRIES' => 1,'DEAD_RETRY' => 1},
@@ -212,7 +222,14 @@ describe 'horizon' do
])
end
it { is_expected.to contain_file(platforms_params[:conf_d_dir]).with_ensure('directory') }
it { is_expected.to contain_file(platforms_params[:conf_d_dir]).with(
:ensure => 'directory',
:mode => '0755',
:purge => true,
:recurse => true,
:owner => platforms_params[:wsgi_user],
:group => platforms_params[:wsgi_group],
) }
it { is_expected.to_not contain_exec('refresh_horizon_django_compress') }
it { is_expected.to contain_file(params[:file_upload_temp_dir]) }