Handle edge cases in staged upgrade hiera data

We make sure the hiera is set in an either-or branches so that we
prevent from executing both at the same time or none at all.

Edge case 1 which is not that much of an edge case --
single-controller environment with Pacemaker. Previously we ran both
branches resulting in duplicate entries.

Edge case 2 -- having the service in roles data but having no node
assigned to that role. In that case previously we wouldn't set the
variables and the upgrade would fail.

Change-Id: I1681a5e5ac7842500fc5e9dd0900ee6121773537
Partial-Bug: #1831690
This commit is contained in:
Jiri Stransky 2019-07-10 15:24:13 +02:00
parent 47d1430da5
commit 2b427970a3
7 changed files with 28 additions and 14 deletions

View File

@ -417,13 +417,15 @@ outputs:
mysql_short_node_names_upgraded: "{{ mysql_short_node_names }}"
mysql_node_names_upgraded: "{{ mysql_node_names }}"
cacheable: no
when: groups['mysql'] | length == 1
when: groups['mysql'] | length <= 1
- name: set mysql upgrade node facts from the limit option
set_fact:
mysql_short_node_names_upgraded: "{{ mysql_short_node_names_upgraded|default([]) + [item.split('.')[0]] }}"
mysql_node_names_upgraded: "{{ mysql_node_names_upgraded|default([]) + [item] }}"
cacheable: no
when: item.split('.')[0] in ansible_limit.split(',')
when:
- groups['mysql'] | length > 1
- item.split('.')[0] in ansible_limit.split(',')
loop: "{{ mysql_node_names }}"
- debug:

View File

@ -355,12 +355,14 @@ outputs:
set_fact:
redis_short_node_names_upgraded: "{{ redis_short_node_names }}"
cacheable: no
when: groups['redis'] | length == 1
when: groups['redis'] | length <= 1
- name: set redis upgrade node facts from the limit option
set_fact:
redis_short_node_names_upgraded: "{{ redis_short_node_names_upgraded|default([]) + [item.split('.')[0]] }}"
cacheable: no
when: item.split('.')[0] in ansible_limit.split(',')
when:
- groups['redis'] | length > 1
- item.split('.')[0] in ansible_limit.split(',')
loop: "{{ redis_short_node_names }}"
- debug:

View File

@ -437,12 +437,14 @@ outputs:
set_fact:
haproxy_short_node_names_upgraded: "{{ haproxy_short_node_names }}"
cacheable: no
when: groups['haproxy'] | length == 1
when: groups['haproxy'] | length <= 1
- name: set haproxy upgrade node facts from the limit option
set_fact:
haproxy_short_node_names_upgraded: "{{ haproxy_short_node_names_upgraded|default([]) + [item.split('.')[0]] }}"
cacheable: no
when: item.split('.')[0] in ansible_limit.split(',')
when:
- groups['haproxy'] | length > 1
- item.split('.')[0] in ansible_limit.split(',')
loop: "{{ haproxy_short_node_names }}"
- debug:

View File

@ -183,12 +183,14 @@ outputs:
set_fact:
pacemaker_short_node_names_upgraded: "{{ pacemaker_short_node_names }}"
cacheable: no
when: groups['pacemaker'] | length == 1
when: groups['pacemaker'] | length <= 1
- name: set pacemaker upgrade node facts from the limit option
set_fact:
pacemaker_short_node_names_upgraded: "{{ pacemaker_short_node_names_upgraded|default([]) + [item.split('.')[0]] }}"
cacheable: no
when: item.split('.')[0] in ansible_limit.split(',')
when:
- groups['pacemaker'] | length > 1
- item.split('.')[0] in ansible_limit.split(',')
loop: "{{ pacemaker_short_node_names }}"
- debug:

View File

@ -316,13 +316,15 @@ outputs:
oslo_messaging_notify_short_node_names_upgraded: "{{ oslo_messaging_notify_short_node_names }}"
oslo_messaging_notify_node_names_upgraded: "{{ oslo_messaging_notify_node_names }}"
cacheable: no
when: groups['oslo_messaging_notify'] | length == 1
when: groups['oslo_messaging_notify'] | length <= 1
- name: set oslo_messaging_notify upgrade node facts from the limit option
set_fact:
oslo_messaging_notify_short_node_names_upgraded: "{{ oslo_messaging_notify_short_node_names_upgraded|default([]) + [item.split('.')[0]] }}"
oslo_messaging_notify_node_names_upgraded: "{{ oslo_messaging_notify_node_names_upgraded|default([]) + [item] }}"
cacheable: no
when: item.split('.')[0] in ansible_limit.split(',')
when:
- groups['oslo_messaging_notify'] | length > 1
- item.split('.')[0] in ansible_limit.split(',')
loop: "{{ oslo_messaging_notify_node_names }}"
- debug:

View File

@ -314,12 +314,14 @@ outputs:
set_fact:
rabbitmq_short_node_names_upgraded: "{{ rabbitmq_short_node_names }}"
cacheable: no
when: groups['rabbitmq'] | length == 1
when: groups['rabbitmq'] | length <= 1
- name: set rabbitmq upgrade node facts from the limit option
set_fact:
rabbitmq_short_node_names_upgraded: "{{ rabbitmq_short_node_names_upgraded|default([]) + [item.split('.')[0]] }}"
cacheable: no
when: item.split('.')[0] in ansible_limit.split(',')
when:
- groups['rabbitmq'] | length > 1
- item.split('.')[0] in ansible_limit.split(',')
loop: "{{ rabbitmq_short_node_names }}"
- debug:

View File

@ -315,13 +315,15 @@ outputs:
oslo_messaging_rpc_short_node_names_upgraded: "{{ oslo_messaging_rpc_short_node_names }}"
oslo_messaging_rpc_node_names_upgraded: "{{ oslo_messaging_rpc_node_names }}"
cacheable: no
when: groups['oslo_messaging_rpc'] | length == 1
when: groups['oslo_messaging_rpc'] | length <= 1
- name: set oslo_messaging_rpc upgrade node facts from the limit option
set_fact:
oslo_messaging_rpc_short_node_names_upgraded: "{{ oslo_messaging_rpc_short_node_names_upgraded|default([]) + [item.split('.')[0]] }}"
oslo_messaging_rpc_node_names_upgraded: "{{ oslo_messaging_rpc_node_names_upgraded|default([]) + [item] }}"
cacheable: no
when: item.split('.')[0] in ansible_limit.split(',')
when:
- groups['oslo_messaging_rpc'] | length > 1
- item.split('.')[0] in ansible_limit.split(',')
loop: "{{ oslo_messaging_rpc_node_names }}"
- debug: