diff --git a/ansible/roles/prometheus/tasks/config_validate.yml b/ansible/roles/prometheus/tasks/config_validate.yml index ed97d539c0..700dba68f5 100644 --- a/ansible/roles/prometheus/tasks/config_validate.yml +++ b/ansible/roles/prometheus/tasks/config_validate.yml @@ -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 diff --git a/doc/source/user/multinode.rst b/doc/source/user/multinode.rst index eab510e49d..21bf67fa45 100644 --- a/doc/source/user/multinode.rst +++ b/doc/source/user/multinode.rst @@ -177,3 +177,19 @@ Run the deployment: kolla-ansible deploy -i +Validate generated configuration files of enabled services: + +.. code-block:: console + + kolla-ansible validate-config -i + +.. 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``. + diff --git a/releasenotes/notes/validate_prometheus_config-45b4bd5e651e61cd.yaml b/releasenotes/notes/validate_prometheus_config-45b4bd5e651e61cd.yaml new file mode 100644 index 0000000000..b6d822a42c --- /dev/null +++ b/releasenotes/notes/validate_prometheus_config-45b4bd5e651e61cd.yaml @@ -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 `__ + for the ``kolla-ansible validate-config`` command for details.