Merge "CI: validate prometheus configs"

This commit is contained in:
Zuul 2024-09-04 02:43:41 +00:00 committed by Gerrit Code Review
commit 99e203e20c
3 changed files with 52 additions and 0 deletions

View File

@ -1 +1,28 @@
---
- name: Validating prometheus config files
vars:
service: "{{ prometheus_services['prometheus-server'] }}"
shell: >-
{{ kolla_container_engine }} exec -i {{ service.container_name }} bash -c
"/opt/prometheus/promtool check config /etc/prometheus/prometheus.yml;
/opt/prometheus/promtool check web-config /etc/prometheus/web.yml"
register: "prometheus_config_validation_results"
check_mode: false
become: true
when:
- inventory_hostname in groups[service.group]
- service.enabled | bool
- name: Assert prometheus config files are valid
vars:
service: "{{ prometheus_services['prometheus-server'] }}"
assert:
that: "prometheus_config_validation_results.rc == 0"
fail_msg: >-
"{{ service.container_name }} config files are invalid, the output was:
{{ prometheus_config_validation_results.stdout }}"
success_msg: >-
"{{ service.container_name }} config files are valid"
when:
- inventory_hostname in groups[service.group]
- service.enabled | bool

View File

@ -177,3 +177,19 @@ Run the deployment:
kolla-ansible deploy -i <path/to/multinode/inventory/file>
Validate generated configuration files of enabled services:
.. code-block:: console
kolla-ansible validate-config -i <path/to/multinode/inventory/file>
.. note::
Due to the nature of the configuration generation the validation can
currently only be done after the first deployment. For some validations
it is necessary to access the running containers.
The validation tasks can be found - and altered - in each ansible role under
``kolla-ansible/ansible/roles/$role/tasks/config_validate.yml``.
The validation for most openstack services is done by the special role:
``service-config-validate``.

View File

@ -0,0 +1,9 @@
---
features:
- |
kolla-ansible now validates the Prometheus configuration files when
called via ``kolla-ansible -i $inventory validate-config``. This
validation is done by running the ``promtool check config`` command.
See the `documentation <https://docs.openstack.org/kolla-ansible/latest/user/multinode.html>`__
for the ``kolla-ansible validate-config`` command for details.