Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commits allows us to restart Ceph daemon machine by machine instead of restarting all the daemons in a single shot. Rework the structure of the handler for clarity as well. Signed-off-by: Sébastien Han <seb@redhat.com> (cherry picked from commit 40a2df5) Conflicts: roles/ceph-common/handlers/main.yml roles/ceph-common/tasks/generate_ceph_conf.yml
- Loading branch information
1 parent
7cfa152
commit ce7ad22
Showing
10 changed files
with
145 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
--- | ||
- name: restart ceph mdss | ||
service: | ||
name: ceph-mds@{{ mds_name }} | ||
state: restarted | ||
# serial: 1 would be the proper solution here, but that can only be set on play level | ||
# upstream issue: https://github.com/ansible/ansible/issues/12170 | ||
run_once: true | ||
with_items: "{{ groups[mds_group_name] }}" | ||
delegate_to: "{{ item }}" | ||
when: | ||
- socket.rc == 0 | ||
- mds_group_name in group_names |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
--- | ||
- name: restart ceph mons | ||
service: | ||
name: ceph-mon@{{ monitor_name }} | ||
state: restarted | ||
# serial: 1 would be the proper solution here, but that can only be set on play level | ||
# upstream issue: https://github.com/ansible/ansible/issues/12170 | ||
run_once: true | ||
with_items: "{{ groups[mon_group_name] }}" | ||
delegate_to: "{{ item }}" | ||
when: | ||
- socket.rc == 0 | ||
- mon_group_name in group_names | ||
|
||
- name: validate monitors | ||
include: validate-mon.yml | ||
when: mon_group_name in group_names |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
--- | ||
# This does not just restart OSDs but everything else too. Unfortunately | ||
# at this time the ansible role does not have an OSD id list to use | ||
# for restarting them specifically. | ||
- name: restart ceph osds | ||
shell: | | ||
for id in $(ls /var/lib/ceph/osd/ |grep -oh '[0-9]*'); do | ||
systemctl restart ceph-osd@$id | ||
sleep 5 | ||
done | ||
# serial: 1 would be the proper solution here, but that can only be set on play level | ||
# upstream issue: https://github.com/ansible/ansible/issues/12170 | ||
run_once: true | ||
with_items: "{{ groups[osd_group_name] }}" | ||
delegate_to: "{{ item }}" | ||
when: | ||
- socket.rc == 0 | ||
- osd_group_name in group_names | ||
|
||
- name: validate osds | ||
include: validate-osd.yml | ||
when: osd_group_name in group_names |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
--- | ||
- name: restart ceph rgws | ||
service: | ||
name: ceph-rgw@{{ ansible_hostname }} | ||
state: restarted | ||
# serial: 1 would be the proper solution here, but that can only be set on play level | ||
# upstream issue: https://github.com/ansible/ansible/issues/12170 | ||
run_once: true | ||
with_items: "{{ groups[rgw_group_name] }}" | ||
delegate_to: "{{ item }}" | ||
when: | ||
- socketrgw.rc == 0 | ||
- rgw_group_name in group_names |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
--- | ||
- name: wait for ceph monitor socket | ||
wait_for: | ||
path: "/var/run/ceph/{{ cluster }}-mon.{{ monitor_name }}.asok" | ||
|
||
- name: set mon_host_count | ||
set_fact: mon_host_count={{ groups[mon_group_name] | length }} | ||
|
||
- name: select a running monitor | ||
set_fact: mon_host={{ item }} | ||
with_items: "{{ groups[mon_group_name] }}" | ||
when: | ||
- item != inventory_hostname | ||
- mon_host_count | int > 1 | ||
|
||
- name: select first monitor if only one monitor | ||
set_fact: mon_host={{ item }} | ||
with_items: "{{ groups[mon_group_name][0] }}" | ||
when: mon_host_count | int == 1 | ||
|
||
- name: waiting for the monitor to join the quorum... | ||
shell: | | ||
ceph -s --cluster {{ cluster }} | grep monmap | sed 's/.*quorum//' | egrep -sq {{ ansible_hostname }} | ||
register: result | ||
until: result.rc == 0 | ||
retries: "{{ handler_health_mon_check_retries }}" | ||
delay: "{{ handler_health_mon_check_delay }}" | ||
delegate_to: "{{ mon_host }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--- | ||
- name: collect osds | ||
shell: | | ||
ls /var/lib/ceph/osd/ |grep -oh '[0-9]*' | ||
register: osd_ids | ||
|
||
- name: wait for ceph osd socket(s) | ||
wait_for: | ||
path: "/var/run/ceph/{{ cluster }}-osd.{{ item }}.asok" | ||
with_items: "{{ osd_ids.stdout_lines }}" | ||
|
||
- name: waiting for clean pgs... | ||
shell: | | ||
test "$(ceph --cluster {{ cluster }} pg stat | sed 's/^.*pgs://;s/active+clean.*//;s/ //')" -eq "$(ceph --cluster {{ cluster }} pg stat | sed 's/pgs.*//;s/^.*://;s/ //')" && ceph --cluster {{ cluster }} health | egrep -sq "HEALTH_OK|HEALTH_WARN" | ||
register: result | ||
until: result.rc == 0 | ||
retries: "{{ handler_health_osd_check_retries }}" | ||
delay: "{{ handler_health_osd_check_delay }}" | ||
delegate_to: "{{ groups[mon_group_name][0] }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters