Skip to content

Commit

Permalink
s/ansible_play_hosts_all/ansible_play_hosts/ where applicable (#51)
Browse files Browse the repository at this point in the history
The ha_cluster role is sometimes included within other roles.
In the scenario when a play is run against multiple hosts, and some of
them fail prior to including the ha_cluster role, the ha_cluster role
must continue only on the active hosts. Otherwise, the ha_cluster role
tries to operate on failed nodes and fails.
  • Loading branch information
spetrosi authored Jun 10, 2022
1 parent 2b24ee4 commit df0ab77
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions tasks/check-and-prepare-role-variables.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
when:
- ha_cluster_sbd_enabled
- >
ansible_play_hosts_all
ansible_play_hosts
| map('extract', hostvars, ['ha_cluster', 'sbd_devices'])
| map('default', [], true)
| map('length') | unique | length > 1
Expand All @@ -32,7 +32,7 @@
- name: Collect cluster node names
set_fact:
__ha_cluster_all_node_names: "{{
ansible_play_hosts_all
ansible_play_hosts
| map('extract', hostvars, '__ha_cluster_node_name')
| list
}}"
Expand Down
2 changes: 1 addition & 1 deletion tasks/cluster-setup-pcs-0.10.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
{% endif %}
--
{{ ha_cluster_cluster_name | quote }}
{% for node in ansible_play_hosts_all %}
{% for node in ansible_play_hosts %}
{{ hostvars[node].__ha_cluster_node_name | quote }}
{%
for addr in hostvars[node].ha_cluster.corosync_addresses | default([])
Expand Down
2 changes: 1 addition & 1 deletion tasks/pcs-auth-pcs-0.10.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# pcs auth tokens in the cluster when not all nodes are auth-ed.
cmd: >
pcs host auth -u hacluster --
{% for node in ansible_play_hosts_all %}
{% for node in ansible_play_hosts %}
{{ hostvars[node].__ha_cluster_node_name | quote }}
{% if hostvars[node].ha_cluster.pcs_address | default("") %}
addr={{ hostvars[node].ha_cluster.pcs_address | quote }}
Expand Down
2 changes: 1 addition & 1 deletion tasks/pcs-auth.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
command:
cmd: >
pcs status pcsd --
{% for node in ansible_play_hosts_all %}
{% for node in ansible_play_hosts %}
{{ hostvars[node].__ha_cluster_node_name | quote }}
{% endfor %}
register: __ha_cluster_pcs_auth_status
Expand Down
2 changes: 1 addition & 1 deletion tasks/presharedkey.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
# Following variables set the fact for all nodes
delegate_facts: yes
delegate_to: "{{ item }}"
with_items: "{{ ansible_play_hosts_all }}"
with_items: "{{ ansible_play_hosts }}"
when:
- not (preshared_key_src is string and preshared_key_src | length > 1)
- not ha_cluster_regenerate_keys

0 comments on commit df0ab77

Please sign in to comment.