tripleo-validations/roles/neutron_sanity_check/tasks/main.yml
Bernard Cafarelli f8d7882f33 Fix neutron_sanity_check for ML2/OVS overcloud
Previously validator failed running on neutron_api as the
neutron-sanity-check binary requires additional capabilities, causing it
to alway fail [0]. In addition, in some cases a race condition in
oslo_privsep can cause the validator to hang indefinitely [1].

This fixes it if the overcloud uses ML2/OVS, using the neutron_ovs_agent
container as we already did on the undercloud, and skipping the check if
it cannot be found (ML2/OVN deployments typically).

Additional fixes to the validator:
* skip gather_facts step
* fix output parsing
* call neutron-sanity-check only once, with all configuration files
  passed to it
* drop redundant default values in playbook itself

[0] https://bugzilla.redhat.com/show_bug.cgi?id=1783195
[1] https://bugzilla.redhat.com/show_bug.cgi?id=1862364

Change-Id: Ifacbbd6a493019e606105f45f0302bf1a88bed62
Co-Authored-By: Cédric Jeanneret <cjeanner@redhat.com>
(cherry picked from commit 3561628f2a)
2020-08-05 08:43:42 +00:00

75 lines
2.4 KiB
YAML

---
- name: Set oc_container_cli and container_name for the Controller
set_fact:
oc_container_cli: "{{ hostvars[inventory_hostname].container_cli | default('podman', true) }}"
container_name: "neutron_ovs_agent"
when: "'Controller' in group_names"
- when: "'Undercloud' in group_names"
block:
- name: Get the path of tripleo undercloud config file
become: true
hiera:
name: "tripleo_undercloud_conf_file"
- name: Get the Container CLI from the undercloud.conf file
become: true
validations_read_ini:
path: "{{ tripleo_undercloud_conf_file }}"
section: DEFAULT
key: container_cli
ignore_missing_file: true
register: container_cli
- name: Set uc_container_cli and container_name for the Undercloud
set_fact:
uc_container_cli: "{{ container_cli.value|default('podman', true) }}"
container_name: "neutron_ovs_agent"
- name: Check if wanted container exists
command: >
{% if oc_container_cli is defined %}{{ oc_container_cli }}{% else %}{{ uc_container_cli }}{% endif %}
ps --filter name={{ container_name }} -q
become: true
register: container_exists
ignore_errors: true
- name: Run sanity check only if container exists
when: container_exists.stdout != ''
block:
- name: Run neutron-sanity-check
command: >
{% if oc_container_cli is defined %}{{ oc_container_cli }}{% else %}{{ uc_container_cli }}{% endif %}
exec -u root {{ container_name }}
/bin/bash -c 'neutron-sanity-check --config-file {{ " --config-file ".join(configs) }} -d'
become: true
register: nsc_return
ignore_errors: true
changed_when: false
- name: Detect errors
set_fact:
has_errors: "{{ nsc_return.stderr_lines
| select('search', '(ERROR)')
| list | length | int > 0 }}"
- name: Detect warnings
set_fact:
has_warnings: "{{ nsc_return.stderr_lines
| select('search', '(WARNING)')
| list | length | int > 0 }}"
- name: Create output
set_fact:
output_msg: "{{ nsc_return.stderr_lines
| select('search', '(ERROR|WARNING)')
| list }}"
- name: Output warning
warn: msg="{{ output_msg | join('\n') }}"
when: has_warnings and not has_errors
- name: Fail
fail: msg="{{ output_msg | join('\n') }}"
when: has_errors