Fix prechecks in check mode

When running in check mode, some prechecks previously failed because
they use the command module which is silently not run in check mode.
Other prechecks were not running correctly in check mode due to e.g.
looking for a string in empty command output or not querying which
containers are running.

This change fixes these issues.

Closes-Bug: #2002657
Change-Id: I5219cb42c48d5444943a2d48106dc338aa08fa7c
This commit is contained in:
Mark Goddard 2023-01-11 16:04:55 +00:00
parent bea4535613
commit 46aeb9843f
53 changed files with 71 additions and 0 deletions

View File

@ -11,6 +11,7 @@
container_engine: "{{ kolla_container_engine }}" container_engine: "{{ kolla_container_engine }}"
name: name:
- aodh_api - aodh_api
check_mode: false
register: container_facts register: container_facts
- name: Checking free port for Aodh API - name: Checking free port for Aodh API

View File

@ -11,6 +11,7 @@
container_engine: "{{ kolla_container_engine }}" container_engine: "{{ kolla_container_engine }}"
name: name:
- barbican_api - barbican_api
check_mode: false
register: container_facts register: container_facts
- name: Checking free port for Barbican API - name: Checking free port for Barbican API

View File

@ -11,6 +11,7 @@
container_engine: "{{ kolla_container_engine }}" container_engine: "{{ kolla_container_engine }}"
name: name:
- blazar_api - blazar_api
check_mode: false
register: container_facts register: container_facts
- name: Checking free port for blazar API - name: Checking free port for blazar API

View File

@ -11,6 +11,7 @@
container_engine: "{{ kolla_container_engine }}" container_engine: "{{ kolla_container_engine }}"
name: name:
- cinder_api - cinder_api
check_mode: false
register: container_facts register: container_facts
- name: Checking free port for Cinder API - name: Checking free port for Cinder API
@ -48,6 +49,7 @@
register: result register: result
changed_when: false changed_when: false
failed_when: result is failed failed_when: result is failed
check_mode: false
when: when:
- enable_cinder | bool - enable_cinder | bool
- enable_cinder_backend_lvm | bool - enable_cinder_backend_lvm | bool

View File

@ -11,6 +11,7 @@
container_engine: "{{ kolla_container_engine }}" container_engine: "{{ kolla_container_engine }}"
name: name:
- cloudkitty_api - cloudkitty_api
check_mode: false
register: container_facts register: container_facts
- name: Checking free port for Cloudkitty API - name: Checking free port for Cloudkitty API

View File

@ -11,6 +11,7 @@
container_engine: "{{ kolla_container_engine }}" container_engine: "{{ kolla_container_engine }}"
name: name:
- cyborg_api - cyborg_api
check_mode: false
register: container_facts register: container_facts
- name: Checking free port for cyborg API - name: Checking free port for cyborg API

View File

@ -13,6 +13,7 @@
- designate_api - designate_api
- designate_backend_bind9 - designate_backend_bind9
- designate_mdns - designate_mdns
check_mode: false
register: container_facts register: container_facts
- name: Checking free port for designate API - name: Checking free port for designate API

View File

@ -11,6 +11,7 @@
container_engine: "{{ kolla_container_engine }}" container_engine: "{{ kolla_container_engine }}"
name: name:
- etcd - etcd
check_mode: false
register: container_facts register: container_facts
- name: Checking free port for Etcd Peer - name: Checking free port for Etcd Peer

View File

@ -11,6 +11,7 @@
container_engine: "{{ kolla_container_engine }}" container_engine: "{{ kolla_container_engine }}"
name: name:
- freezer_api - freezer_api
check_mode: false
register: container_facts register: container_facts
- name: Checking free port for Freezer API - name: Checking free port for Freezer API

View File

@ -10,6 +10,7 @@
kolla_container_facts: kolla_container_facts:
container_engine: "{{ kolla_container_engine }}" container_engine: "{{ kolla_container_engine }}"
name: "{{ glance_services.values() | map(attribute='container_name') | list }}" name: "{{ glance_services.values() | map(attribute='container_name') | list }}"
check_mode: false
register: container_facts register: container_facts
- name: Checking free port for Glance API - name: Checking free port for Glance API

View File

@ -11,6 +11,7 @@
container_engine: "{{ kolla_container_engine }}" container_engine: "{{ kolla_container_engine }}"
name: name:
- gnocchi_api - gnocchi_api
check_mode: false
register: container_facts register: container_facts
- name: Checking free port for Gnocchi API - name: Checking free port for Gnocchi API

View File

@ -11,6 +11,7 @@
container_engine: "{{ kolla_container_engine }}" container_engine: "{{ kolla_container_engine }}"
name: name:
- grafana - grafana
check_mode: false
register: container_facts register: container_facts
- name: Checking free port for Grafana server - name: Checking free port for Grafana server

View File

@ -5,6 +5,7 @@
container_engine: "{{ kolla_container_engine }}" container_engine: "{{ kolla_container_engine }}"
name: name:
- hacluster_pacemaker_remote - hacluster_pacemaker_remote
check_mode: false
register: container_facts register: container_facts
# NOTE(yoctozepto): Corosync runs over UDP so one cannot use wait_for to check # NOTE(yoctozepto): Corosync runs over UDP so one cannot use wait_for to check

View File

@ -11,6 +11,7 @@
container_engine: "{{ kolla_container_engine }}" container_engine: "{{ kolla_container_engine }}"
name: name:
- influxdb - influxdb
check_mode: false
register: container_facts register: container_facts
- name: Checking free port for Influxdb Http - name: Checking free port for Influxdb Http

View File

@ -13,6 +13,7 @@
- ironic_api - ironic_api
- ironic_inspector - ironic_inspector
- ironic_http - ironic_http
check_mode: false
register: container_facts register: container_facts
- name: Checking free port for Ironic API - name: Checking free port for Ironic API

View File

@ -11,6 +11,7 @@
container_engine: "{{ kolla_container_engine }}" container_engine: "{{ kolla_container_engine }}"
name: name:
- iscsid - iscsid
check_mode: false
register: container_facts register: container_facts
- name: Checking free port for iscsi - name: Checking free port for iscsi

View File

@ -12,6 +12,7 @@
name: name:
- keystone - keystone
- keystone_ssh - keystone_ssh
check_mode: false
register: container_facts register: container_facts
- name: Checking free port for Keystone Public - name: Checking free port for Keystone Public

View File

@ -11,6 +11,7 @@
container_engine: "{{ kolla_container_engine }}" container_engine: "{{ kolla_container_engine }}"
name: name:
- kuryr - kuryr
check_mode: false
register: container_facts register: container_facts
- name: Checking free port for Kuryr - name: Checking free port for Kuryr

View File

@ -13,12 +13,14 @@
- haproxy - haproxy
- proxysql - proxysql
- keepalived - keepalived
check_mode: false
register: container_facts register: container_facts
- name: Group hosts by whether they are running keepalived - name: Group hosts by whether they are running keepalived
group_by: group_by:
key: "keepalived_running_{{ container_facts['keepalived'] is defined }}" key: "keepalived_running_{{ container_facts['keepalived'] is defined }}"
changed_when: false changed_when: false
check_mode: false
when: when:
- enable_keepalived | bool - enable_keepalived | bool
- inventory_hostname in groups['loadbalancer'] - inventory_hostname in groups['loadbalancer']
@ -27,6 +29,7 @@
group_by: group_by:
key: "haproxy_running_{{ container_facts['haproxy'] is defined }}" key: "haproxy_running_{{ container_facts['haproxy'] is defined }}"
changed_when: false changed_when: false
check_mode: false
when: when:
- enable_haproxy | bool - enable_haproxy | bool
- inventory_hostname in groups['loadbalancer'] - inventory_hostname in groups['loadbalancer']
@ -35,6 +38,7 @@
group_by: group_by:
key: "proxysql_running_{{ container_facts['proxysql'] is defined }}" key: "proxysql_running_{{ container_facts['proxysql'] is defined }}"
changed_when: false changed_when: false
check_mode: false
when: when:
- enable_proxysql | bool - enable_proxysql | bool
- inventory_hostname in groups['loadbalancer'] - inventory_hostname in groups['loadbalancer']
@ -108,6 +112,7 @@
register: ping_output register: ping_output
changed_when: false changed_when: false
failed_when: ping_output.rc != 1 failed_when: ping_output.rc != 1
check_mode: false
with_items: with_items:
- "{{ kolla_internal_vip_address }}" - "{{ kolla_internal_vip_address }}"
- "{{ kolla_external_vip_address }}" - "{{ kolla_external_vip_address }}"
@ -187,6 +192,7 @@
failed_when: >- failed_when: >-
( ip_addr_output is failed or ( ip_addr_output is failed or
kolla_internal_vip_address | ipaddr(ip_addr_output.stdout.split()[3]) is none) kolla_internal_vip_address | ipaddr(ip_addr_output.stdout.split()[3]) is none)
check_mode: false
when: when:
- enable_haproxy | bool - enable_haproxy | bool
- enable_keepalived | bool - enable_keepalived | bool
@ -198,6 +204,7 @@
shell: echo "show stat" | {{ kolla_container_engine }} exec -i haproxy socat unix-connect:/var/lib/kolla/haproxy/haproxy.sock stdio # noqa risky-shell-pipe shell: echo "show stat" | {{ kolla_container_engine }} exec -i haproxy socat unix-connect:/var/lib/kolla/haproxy/haproxy.sock stdio # noqa risky-shell-pipe
register: haproxy_stat_shell register: haproxy_stat_shell
changed_when: false changed_when: false
check_mode: false
when: container_facts['haproxy'] is defined when: container_facts['haproxy'] is defined
- name: Setting haproxy stat fact - name: Setting haproxy stat fact
@ -827,6 +834,7 @@
register: firewalld_is_active register: firewalld_is_active
changed_when: false changed_when: false
failed_when: false failed_when: false
check_mode: false
- name: Fail if firewalld is not running - name: Fail if firewalld is not running
fail: fail:

View File

@ -11,6 +11,7 @@
container_engine: "{{ kolla_container_engine }}" container_engine: "{{ kolla_container_engine }}"
name: name:
- magnum_api - magnum_api
check_mode: false
register: container_facts register: container_facts
- name: Checking free port for Magnum API - name: Checking free port for Magnum API

View File

@ -11,6 +11,7 @@
container_engine: "{{ kolla_container_engine }}" container_engine: "{{ kolla_container_engine }}"
name: name:
- manila_api - manila_api
check_mode: false
register: container_facts register: container_facts
- name: Checking free port for Manila API - name: Checking free port for Manila API

View File

@ -11,6 +11,7 @@
container_engine: "{{ kolla_container_engine }}" container_engine: "{{ kolla_container_engine }}"
name: name:
- mariadb - mariadb
check_mode: false
register: container_facts register: container_facts
- name: Checking free port for MariaDB - name: Checking free port for MariaDB

View File

@ -11,6 +11,7 @@
container_engine: "{{ kolla_container_engine }}" container_engine: "{{ kolla_container_engine }}"
name: name:
- masakari_api - masakari_api
check_mode: false
register: container_facts register: container_facts
- name: Checking free port for Masakari API - name: Checking free port for Masakari API

View File

@ -11,6 +11,7 @@
container_engine: "{{ kolla_container_engine }}" container_engine: "{{ kolla_container_engine }}"
name: name:
- memcached - memcached
check_mode: false
register: container_facts register: container_facts
- name: Checking free port for Memcached - name: Checking free port for Memcached

View File

@ -11,6 +11,7 @@
container_engine: "{{ kolla_container_engine }}" container_engine: "{{ kolla_container_engine }}"
name: name:
- mistral_api - mistral_api
check_mode: false
register: container_facts register: container_facts
- name: Checking free port for Mistral API - name: Checking free port for Mistral API

View File

@ -11,6 +11,7 @@
container_engine: "{{ kolla_container_engine }}" container_engine: "{{ kolla_container_engine }}"
name: name:
- murano_api - murano_api
check_mode: false
register: container_facts register: container_facts
- name: Checking free port for Murano API - name: Checking free port for Murano API

View File

@ -11,6 +11,7 @@
container_engine: "{{ kolla_container_engine }}" container_engine: "{{ kolla_container_engine }}"
name: name:
- neutron_server - neutron_server
check_mode: false
register: container_facts register: container_facts
- name: Checking free port for Neutron Server - name: Checking free port for Neutron Server

View File

@ -15,6 +15,7 @@
- nova_serialproxy - nova_serialproxy
- nova_spicehtml5proxy - nova_spicehtml5proxy
- nova_ssh - nova_ssh
check_mode: false
register: container_facts register: container_facts
- name: Checking available compute nodes in inventory - name: Checking available compute nodes in inventory

View File

@ -11,6 +11,7 @@
container_engine: "{{ kolla_container_engine }}" container_engine: "{{ kolla_container_engine }}"
name: name:
- nova_api - nova_api
check_mode: false
register: container_facts register: container_facts
- name: Checking free port for Nova API - name: Checking free port for Nova API

View File

@ -12,6 +12,7 @@
name: name:
- octavia_api - octavia_api
- octavia_health_manager - octavia_health_manager
check_mode: false
register: container_facts register: container_facts
- name: Checking free port for Octavia API - name: Checking free port for Octavia API

View File

@ -12,6 +12,7 @@
name: name:
- opensearch - opensearch
- elasticsearch - elasticsearch
check_mode: false
register: container_facts register: container_facts
- name: Checking free port for Opensearch - name: Checking free port for Opensearch

View File

@ -11,6 +11,7 @@
container_engine: "{{ kolla_container_engine }}" container_engine: "{{ kolla_container_engine }}"
name: name:
- openvswitch_db - openvswitch_db
check_mode: false
register: container_facts register: container_facts
- name: Checking free port for OVSDB - name: Checking free port for OVSDB

View File

@ -6,6 +6,7 @@
name: name:
- ovn_nb_db - ovn_nb_db
- ovn_sb_db - ovn_sb_db
check_mode: false
register: container_facts register: container_facts
- name: Checking free port for OVN northbound db - name: Checking free port for OVN northbound db

View File

@ -11,6 +11,7 @@
container_engine: "{{ kolla_container_engine }}" container_engine: "{{ kolla_container_engine }}"
name: name:
- placement_api - placement_api
check_mode: false
register: container_facts register: container_facts
- name: Checking free port for Placement API - name: Checking free port for Placement API

View File

@ -23,6 +23,7 @@
command: grep -q Stream /etc/os-release command: grep -q Stream /etc/os-release
register: stream_status register: stream_status
changed_when: false changed_when: false
check_mode: false
when: when:
- ansible_facts.distribution == 'CentOS' - ansible_facts.distribution == 'CentOS'

View File

@ -3,6 +3,7 @@
command: "{{ ansible_facts.python.executable }} -c \"import docker; print(docker.__version__)\"" command: "{{ ansible_facts.python.executable }} -c \"import docker; print(docker.__version__)\""
register: result register: result
changed_when: false changed_when: false
check_mode: false
when: when:
- inventory_hostname in groups['baremetal'] - inventory_hostname in groups['baremetal']
- kolla_container_engine == 'docker' - kolla_container_engine == 'docker'

View File

@ -4,6 +4,7 @@
command: "{{ kolla_container_engine }} --version" command: "{{ kolla_container_engine }} --version"
register: result register: result
changed_when: false changed_when: false
check_mode: false
when: inventory_hostname in groups['baremetal'] when: inventory_hostname in groups['baremetal']
failed_when: result is failed failed_when: result is failed
or result.stdout | regex_replace('.*\\b(\\d+\\.\\d+\\.\\d+)\\b.*', '\\1') is version(docker_version_min, '<') or result.stdout | regex_replace('.*\\b(\\d+\\.\\d+\\.\\d+)\\b.*', '\\1') is version(docker_version_min, '<')
@ -19,12 +20,14 @@
register: result register: result
changed_when: false changed_when: false
failed_when: result.stdout | regex_replace('(.*ssh_key.*)', '') is search(":") failed_when: result.stdout | regex_replace('(.*ssh_key.*)', '') is search(":")
check_mode: false
- name: Check if nscd is running - name: Check if nscd is running
command: pgrep nscd command: pgrep nscd
ignore_errors: yes ignore_errors: yes
failed_when: false failed_when: false
changed_when: false changed_when: false
check_mode: false
register: nscd_status register: nscd_status
- name: Fail if nscd is running - name: Fail if nscd is running

View File

@ -14,6 +14,7 @@
register: systemctl_is_active register: systemctl_is_active
changed_when: false changed_when: false
failed_when: false failed_when: false
check_mode: false
- name: Fail if a host NTP daemon is not running - name: Fail if a host NTP daemon is not running
fail: fail:
@ -31,6 +32,7 @@
command: timedatectl status command: timedatectl status
register: timedatectl_status register: timedatectl_status
changed_when: false changed_when: false
check_mode: false
- name: Fail if the clock is not synchronized - name: Fail if the clock is not synchronized
fail: fail:

View File

@ -17,3 +17,4 @@
register: result register: result
failed_when: result is failed failed_when: result is failed
changed_when: False changed_when: False
check_mode: false

View File

@ -22,6 +22,7 @@
- prometheus_blackbox_exporter - prometheus_blackbox_exporter
- prometheus_libvirt_exporter - prometheus_libvirt_exporter
- prometheus_msteams - prometheus_msteams
check_mode: false
register: container_facts register: container_facts
- name: Checking free port for Prometheus server - name: Checking free port for Prometheus server

View File

@ -12,6 +12,7 @@
name: name:
- rabbitmq - rabbitmq
- outward_rabbitmq - outward_rabbitmq
check_mode: false
register: container_facts register: container_facts
- name: Checking free port for RabbitMQ - name: Checking free port for RabbitMQ
@ -63,6 +64,7 @@
nss_database: "{{ 'ahostsv4' if api_address_family == 'ipv4' else 'ahostsv6' }}" nss_database: "{{ 'ahostsv4' if api_address_family == 'ipv4' else 'ahostsv6' }}"
command: "getent {{ nss_database }} {{ hostvars[item].ansible_facts.hostname }}" command: "getent {{ nss_database }} {{ hostvars[item].ansible_facts.hostname }}"
changed_when: false changed_when: false
check_mode: false
register: rabbitmq_hostnames register: rabbitmq_hostnames
with_items: "{{ groups['rabbitmq'] }}" with_items: "{{ groups['rabbitmq'] }}"
@ -150,6 +152,7 @@
nss_database: "{{ 'ahostsv4' if api_address_family == 'ipv4' else 'ahostsv6' }}" nss_database: "{{ 'ahostsv4' if api_address_family == 'ipv4' else 'ahostsv6' }}"
command: "getent {{ nss_database }} {{ hostvars[item].ansible_facts.hostname }}" command: "getent {{ nss_database }} {{ hostvars[item].ansible_facts.hostname }}"
changed_when: false changed_when: false
check_mode: false
register: outward_rabbitmq_hostnames register: outward_rabbitmq_hostnames
with_items: "{{ groups['outward-rabbitmq'] }}" with_items: "{{ groups['outward-rabbitmq'] }}"
when: when:

View File

@ -11,6 +11,7 @@
container_engine: "{{ kolla_container_engine }}" container_engine: "{{ kolla_container_engine }}"
name: name:
- redis - redis
check_mode: false
register: container_facts register: container_facts
- name: Checking free port for Redis - name: Checking free port for Redis

View File

@ -11,6 +11,7 @@
container_engine: "{{ kolla_container_engine }}" container_engine: "{{ kolla_container_engine }}"
name: name:
- sahara_api - sahara_api
check_mode: false
register: container_facts register: container_facts
- name: Checking free port for Sahara API - name: Checking free port for Sahara API

View File

@ -11,6 +11,7 @@
container_engine: "{{ kolla_container_engine }}" container_engine: "{{ kolla_container_engine }}"
name: name:
- senlin_api - senlin_api
check_mode: false
register: container_facts register: container_facts
- name: Checking free port for Senlin API - name: Checking free port for Senlin API

View File

@ -11,6 +11,7 @@
container_engine: "{{ kolla_container_engine }}" container_engine: "{{ kolla_container_engine }}"
name: name:
- solum_api - solum_api
check_mode: false
register: container_facts register: container_facts
- name: Checking free port for Solum Application Deployment - name: Checking free port for Solum Application Deployment

View File

@ -14,6 +14,7 @@
- swift_container_server - swift_container_server
- swift_object_server - swift_object_server
- swift_proxy_server - swift_proxy_server
check_mode: false
register: container_facts register: container_facts
- name: Checking free port for Swift Account Server - name: Checking free port for Swift Account Server

View File

@ -11,6 +11,7 @@
container_engine: "{{ kolla_container_engine }}" container_engine: "{{ kolla_container_engine }}"
name: name:
- tacker_server - tacker_server
check_mode: false
register: container_facts register: container_facts
- name: Checking free port for Tacker Server - name: Checking free port for Tacker Server

View File

@ -11,6 +11,7 @@
container_engine: "{{ kolla_container_engine }}" container_engine: "{{ kolla_container_engine }}"
name: name:
- trove_api - trove_api
check_mode: false
register: container_facts register: container_facts
- name: Checking free port for Trove API - name: Checking free port for Trove API

View File

@ -11,6 +11,7 @@
container_engine: "{{ kolla_container_engine }}" container_engine: "{{ kolla_container_engine }}"
name: name:
- venus_api - venus_api
check_mode: false
register: container_facts register: container_facts
- name: Checking free port for Venus API - name: Checking free port for Venus API

View File

@ -11,6 +11,7 @@
container_engine: "{{ kolla_container_engine }}" container_engine: "{{ kolla_container_engine }}"
name: name:
- vitrage_api - vitrage_api
check_mode: false
register: container_facts register: container_facts
- name: Checking free port for vitrage API - name: Checking free port for vitrage API

View File

@ -11,6 +11,7 @@
container_engine: "{{ kolla_container_engine }}" container_engine: "{{ kolla_container_engine }}"
name: name:
- watcher_api - watcher_api
check_mode: false
register: container_facts register: container_facts
- name: Checking free port for watcher API - name: Checking free port for watcher API

View File

@ -13,6 +13,7 @@
- zun_api - zun_api
- zun_wsproxy - zun_wsproxy
- zun_cni_daemon - zun_cni_daemon
check_mode: false
register: container_facts register: container_facts
- name: Checking free port for Zun API - name: Checking free port for Zun API

View File

@ -0,0 +1,6 @@
---
fixes:
- |
Fixes an issue where some prechecks would fail or not run when running in
check mode. `LP#2002657
<https://bugs.launchpad.net/kolla-ansible/+bug/2002657>`__