Ensure conditionals are proper booleans

In order to avoid broken conditionals error in Ansible
we need to ensure that variables are proper booleans at all times.

Change-Id: Ic43f934d594fee0268f731a7fec74fa2d0cb767a
Signed-off-by: Dmitriy Rabotyagov <dmitriy.rabotyagov@cleura.com>
This commit is contained in:
Dmitriy Rabotyagov
2026-02-25 10:35:00 +01:00
parent a9eb07085c
commit deec12f083
3 changed files with 10 additions and 7 deletions

View File

@@ -3,6 +3,9 @@ collections:
- name: https://opendev.org/openstack/ansible-config_template
version: master
type: git
- name: https://opendev.org/openstack/openstack-ansible-plugins
version: master
type: git
- name: community.crypto
source: https://github.com/ansible-collections/community.crypto
type: git

View File

@@ -79,7 +79,7 @@
- name: Including rabbitmq_setup tasks
ansible.builtin.include_tasks: rabbitmq_setup.yml
when:
- _rabbitmq_is_last_play_host
- _rabbitmq_is_last_play_host | bool
args:
apply:
tags:
@@ -89,8 +89,8 @@
- name: Ensure all flags are set after upgrade is done
when:
- _rabbitmq_is_last_play_host
- rabbitmq_upgrade
- _rabbitmq_is_last_play_host | bool
- rabbitmq_upgrade | bool
block:
- name: Including rabbitmq_cluster_state tasks
ansible.builtin.include_tasks: rabbitmq_cluster_state.yml
@@ -110,7 +110,7 @@
tags:
- rabbitmq-upgrade
when:
- _cluster_state
- _cluster_state | length > 0
- (_cluster_state.get('running_nodes', []) | length) == (groups[rabbitmq_host_group] | length)
- (_cluster_state.get('alarms', []) | length) == 0
- (_cluster_state.get('partitions', []) | length) == 0

View File

@@ -120,7 +120,7 @@
any_errors_fatal: true
when:
- rabbitmq_upgrade | bool
- _cluster_state
- _cluster_state | length > 0
- _rabbitmq_cluster_upgrade_blockers | length > 0
tags:
- rabbitmq-upgrade
@@ -131,7 +131,7 @@
_rabbitmq_quorum_critical_queues: "{{ (_rabbitmq_is_quorum_critical.stderr | from_json)['queues'] }}"
when:
- rabbitmq_upgrade | bool
- _cluster_state
- _cluster_state | length > 0
tags:
- rabbitmq-upgrade
block:
@@ -185,7 +185,7 @@
- name: Prepare node for upgrade
when:
- rabbitmq_upgrade | bool
- _cluster_state
- _cluster_state | length > 0
- (_cluster_state.get('running_nodes', []) | length) == (groups[rabbitmq_host_group] | length)
- (_cluster_state.get('alarms', []) | length) == 0
- (_cluster_state.get('partitions', []) | length) == 0