mirror of https://github.com/ceph/ceph-ansible.git
rolling_update: fix active mds host value
The active mds host should be based on the inventory hostname and not on
the ansible hostname.
The value returns under the mdsmap structure is based on the OS hostname
so we need to find the right node in the inventory with this value when
doing operation on inventory nodes.
Othewise we could see error like:
The task includes an option with an undefined variable. The error was:
"hostvars[foobar]" is undefined
Signed-off-by: Dimitri Savineau <dsavinea@redhat.com>
(cherry picked from commit f1f2352c79
)
pull/4693/head
parent
4b667b2f37
commit
bd79b4480a
|
@ -515,6 +515,11 @@
|
||||||
mds_active_name: "{{ (_mds_active_name.stdout | from_json)['info'][item.key]['name'] }}"
|
mds_active_name: "{{ (_mds_active_name.stdout | from_json)['info'][item.key]['name'] }}"
|
||||||
with_dict: "{{ (_mds_active_name.stdout | from_json).info }}"
|
with_dict: "{{ (_mds_active_name.stdout | from_json).info }}"
|
||||||
|
|
||||||
|
- name: set_fact mds_active_host
|
||||||
|
set_fact:
|
||||||
|
mds_active_host: "{{ hostvars[item]['inventory_hostname'] }}"
|
||||||
|
with_items: "{{ groups[mds_group_name] }}"
|
||||||
|
when: hostvars[item]['ansible_hostname'] == mds_active_name
|
||||||
|
|
||||||
- name: create standby_mdss group
|
- name: create standby_mdss group
|
||||||
add_host:
|
add_host:
|
||||||
|
@ -522,7 +527,7 @@
|
||||||
groups: standby_mdss
|
groups: standby_mdss
|
||||||
ansible_host: "{{ hostvars[item]['ansible_host'] | default(omit) }}"
|
ansible_host: "{{ hostvars[item]['ansible_host'] | default(omit) }}"
|
||||||
ansible_port: "{{ hostvars[item]['ansible_port'] | default(omit) }}"
|
ansible_port: "{{ hostvars[item]['ansible_port'] | default(omit) }}"
|
||||||
with_items: "{{ groups[mds_group_name] | difference(mds_active_name) }}"
|
with_items: "{{ groups[mds_group_name] | difference(mds_active_host) }}"
|
||||||
|
|
||||||
- name: stop standby ceph mds
|
- name: stop standby ceph mds
|
||||||
systemd:
|
systemd:
|
||||||
|
@ -553,10 +558,10 @@
|
||||||
|
|
||||||
- name: create active_mdss group
|
- name: create active_mdss group
|
||||||
add_host:
|
add_host:
|
||||||
name: "{{ mds_active_name if mds_active_name is defined else groups.get(mds_group_name)[0] }}"
|
name: "{{ mds_active_host if mds_active_host is defined else groups.get(mds_group_name)[0] }}"
|
||||||
groups: active_mdss
|
groups: active_mdss
|
||||||
ansible_host: "{{ hostvars[mds_active_name if mds_active_name is defined else groups.get(mds_group_name)[0]]['ansible_host'] | default(omit) }}"
|
ansible_host: "{{ hostvars[mds_active_host if mds_active_host is defined else groups.get(mds_group_name)[0]]['ansible_host'] | default(omit) }}"
|
||||||
ansible_port: "{{ hostvars[mds_active_name if mds_active_name is defined else groups.get(mds_group_name)[0]]['ansible_port'] | default(omit) }}"
|
ansible_port: "{{ hostvars[mds_active_host if mds_active_host is defined else groups.get(mds_group_name)[0]]['ansible_port'] | default(omit) }}"
|
||||||
|
|
||||||
|
|
||||||
- name: upgrade active mds
|
- name: upgrade active mds
|
||||||
|
|
Loading…
Reference in New Issue