Delete policy file if policies hash is empty

If all policies get deleted, previously created policy files won't
get removed and the api policy file is still is used. Lets make
sure the policy file gets purged if the policies hash is empty.

Depends-On: https://review.opendev.org/c/openstack/puppet-openstacklib/+/802305
Change-Id: Ic9b5ccd8fc23f6cebc06f62d972b64efd2400396
This commit is contained in:
Martin Schuppert 2021-07-26 11:47:33 +02:00
parent 212ac22431
commit 70c6d31150
1 changed files with 14 additions and 6 deletions

View File

@ -36,12 +36,18 @@
# (Optional) Path to the nova policy folder
# Defaults to $::os_service_default
#
# [*purge_config*]
# (optional) Whether to set only the specified policy rules in the policy
# file.
# Defaults to false.
#
class nova::policy (
$enforce_scope = $::os_service_default,
$enforce_new_defaults = $::os_service_default,
$policies = {},
$policy_path = '/etc/nova/policy.yaml',
$policy_dirs = $::os_service_default,
$purge_config = false,
) {
include nova::deps
@ -49,14 +55,16 @@ class nova::policy (
validate_legacy(Hash, 'validate_hash', $policies)
Openstacklib::Policy::Base {
file_path => $policy_path,
file_user => 'root',
file_group => $::nova::params::group,
file_format => 'yaml',
$policy_defaults = {
policies => $policies,
policy_path => $policy_path,
file_user => 'root',
file_group => $::nova::params::group,
file_format => 'yaml',
purge_config => $purge_config,
}
create_resources('openstacklib::policy::base', $policies)
ensure_resource('openstacklib::policy', $policy_path, $policy_defaults)
oslo::policy { 'nova_config':
enforce_scope => $enforce_scope,