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 remove
the policy file if the policies hash is empty.

Change-Id: Ic9b5ccd8fc23f6cebc06f62d972b64efd2400396
This commit is contained in:
Martin Schuppert 2021-07-26 11:47:33 +02:00
parent 212ac22431
commit 58af07ac06
1 changed files with 14 additions and 7 deletions

View File

@ -49,14 +49,21 @@ 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',
}
if empty($policies){
file {$policy_path:
path => $policy_path,
ensure => absent,
}
} else {
Openstacklib::Policy::Base {
file_path => $policy_path,
file_user => 'root',
file_group => $::nova::params::group,
file_format => 'yaml',
}
create_resources('openstacklib::policy::base', $policies)
create_resources('openstacklib::policy::base', $policies)
}
oslo::policy { 'nova_config':
enforce_scope => $enforce_scope,