Ensure that first/last host detection is deterministic

With ansible-core 2.16 a breaking changes landed [1] to some filters
making their result returned in arbitrary order. With that, we were
relying on them to always return exactly same ordered lists.

With that we need to ensure that we still have determenistic behaviour
where this is important.

[1] https://github.com/ansible/ansible/issues/82554

Depends-On: https://review.opendev.org/c/openstack/openstack-ansible/+/927841
Change-Id: I9b0c090d69bd9a86da9f8d877a4c561b22f8a028
This commit is contained in:
Dmitriy Rabotyagov 2024-07-22 16:34:13 +02:00
parent 23bf80b731
commit 9c4ff72a6c
3 changed files with 10 additions and 8 deletions

View File

@ -90,8 +90,7 @@
- common-mq
- zun-config
when:
- "zun_services['zun-api']['group'] in group_names"
- "inventory_hostname == ((groups[zun_services['zun-api']['group']] | intersect(ansible_play_hosts)) | list)[0]"
- _zun_is_first_play_host
vars:
_oslomsg_rpc_setup_host: "{{ zun_oslomsg_rpc_setup_host }}"
_oslomsg_rpc_userid: "{{ zun_oslomsg_rpc_userid }}"
@ -128,8 +127,7 @@
- username: "{{ zun_galera_user }}"
password: "{{ zun_galera_password }}"
when:
- "zun_services['zun-api']['group'] in group_names"
- "inventory_hostname == ((groups['zun_api'] | intersect(ansible_play_hosts)) | list)[0]"
- _zun_is_first_play_host
tags:
- always
@ -169,8 +167,7 @@
type: "{{ zun_service_type }}"
description: "{{ zun_service_description }}"
when:
- "zun_services['zun-api']['group'] in group_names"
- "inventory_hostname == ((groups['zun_api'] | intersect(ansible_play_hosts)) | list)[0]"
- _zun_is_first_play_host
tags:
- always

View File

@ -84,5 +84,4 @@
become_user: "{{ zun_system_user_name }}"
changed_when: false
when:
- zun_services['zun-api']['group'] in group_names
- inventory_hostname == ((groups['zun_api'] | intersect(ansible_play_hosts)) | list)[0]
- _zun_is_first_play_host

View File

@ -13,6 +13,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.
_zun_is_first_play_host: >-
{{
(zun_services['zun-api']['group'] in group_names and
inventory_hostname == groups[zun_services['zun-api']['group']] | select('in', ansible_play_hosts) | first) | bool
}}
_zun_oslomsg_rpc_vhost_conf: >-
{{
(zun_oslomsg_rpc_vhost is string) | ternary(