tripleo-validations/roles/oslo_config_validator/tasks/main.yml

73 lines
2.3 KiB
YAML

---
# Copyright 2021 Red Hat, Inc.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
# tasks
- name: Include the config builder tasks
include_tasks: build_validation_config.yml
- name: Validate configuration
when:
- 'oslo_config_validator_validation | bool or
oslo_config_validator_report | bool'
include_tasks: validate_config.yml
- name: Invalidate configuration
when:
- oslo_config_validator_invalid_settings | bool
include_tasks: invalidate_config.yml
- name: Config validation reporting
when:
- oslo_config_validator_report | bool
include_tasks: report_generation.yml
- name: Config validation assertions
block:
- name: Verifying setting validation
assert:
that:
- not service.output | count
fail_msg: |
Config file {{ service.config_file }} for {{ service.service }} has returned validation errors:
{% for msg in service.output %}
{{ msg }}
{% endfor %}
loop: "{{ validation_output }}"
loop_control:
loop_var: service
label: "{{ service.config_file }}/{{ service.service }}"
register: validation_errors
ignore_errors: true
- name: Asserted failure
when: "'failed' in validation_errors or
(invalid_settings is defined and
invalid_settings | count)"
fail:
msg: |
Configuration validation failed for at least one service:
{%
if validation_errors.results | count %}{%
for service in validation_errors.results %}{%
if service.failed %}{{ service.msg }}{% endif %}{%
endfor %}{%
endif %}{%
if invalid_settings is defined and invalid_settings | count %}{%
for message in invalid_settings %}{{ message }}
{% endfor %}{%
endif %}