oslo_config_validator: Adding possibility to override namespaces config

It might be a good idea to override specific namespace config from
the playbook as it gives more flexibility to operators when it's time
to validate settings. This commit adds the option to have a namespaces
config override that will override the default namespace configs.

Change-Id: I3fb67afb25c8bb3185ad8febd8fa8257bcb4085f
This commit is contained in:
David Vallee Delisle 2022-02-02 17:14:07 -05:00
parent 9068edeb20
commit 6de2be5706
3 changed files with 36 additions and 2 deletions

View File

@ -29,6 +29,21 @@
- identity
products:
- tripleo
# Overriding simple namespaces config can be done on a per-namespace basis.
# We simply need to add a dict to this list of dictionnary. It will replace
# its corresponding entry from the default config
# This is usefull if we want to target the validation on a set of hosts
# that would otherwise trigger an error.
# oslo_config_validator_namespaces_config_override:
# - namespace: nova.conf
# invalid_settings:
# - section: filter_scheduler
# option: enabled_filters
# separator: ","
# value_list:
# - SomeBadFilter
# Debug log level
oslo_config_validator_debug: false
@ -68,5 +83,6 @@
- placement
- neutron
- keystone
roles:
- oslo_config_validator

View File

@ -44,6 +44,24 @@
debug:
var: service_config
- name: Overriding namespace configuration
set_fact:
namespaces_config: >-
{% set override_config = [] %}{%
for config in oslo_config_validator_namespaces_config | default([]) %}{%
set _ = override_config.append(
oslo_config_validator_namespaces_config_override | default([]) |
selectattr('namespace', 'eq', config.namespace) | first | default(config, true)
) %}{%
endfor %}{{
override_config }}
- name: Printing overriden namespace config
when:
- oslo_config_validator_debug | bool
debug:
var: namespaces_config
- name: podman - Gather facts for all containers
become: true
containers.podman.podman_container_info:
@ -133,7 +151,7 @@
%}{%
if svc_config | count %}{%
for ns in svc_config[0].namespaces | list %}{%
set ns_config = oslo_config_validator_namespaces_config |
set ns_config = namespaces_config |
selectattr('namespace', 'equalto', ns) |
selectattr('invalid_settings', 'defined') | list %}{%
if ns_config | count %}{%

View File

@ -42,7 +42,7 @@
set_fact:
validation_output: >-
{% set ignored_patterns = oslo_config_validator_global_ignored_messages | default("") %}{%
for ns in oslo_config_validator_namespaces_config | default([]) %}{%
for ns in namespaces_config | default([]) %}{%
if ns.namespace in out.config_file.namespaces %}{%
for ignored in ns.ignored_messages | default([]) %}{%
set _ = ignored_patterns.append(ignored) %}{%