2019-10-10 01:58:33 +08:00
|
|
|
---
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Set_fact trigger_restart
|
|
|
|
ansible.builtin.set_fact:
|
2021-06-15 00:01:41 +08:00
|
|
|
trigger_restart: true
|
|
|
|
loop: "{{ groups[osd_group_name] }}"
|
|
|
|
when: hostvars[item]['handler_osd_status'] | default(False) | bool
|
2020-01-17 22:50:40 +08:00
|
|
|
run_once: true
|
2019-07-09 21:40:47 +08:00
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Osd handler
|
2021-06-15 00:01:41 +08:00
|
|
|
when: trigger_restart | default(False) | bool
|
|
|
|
block:
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Set _osd_handler_called before restart
|
|
|
|
ansible.builtin.set_fact:
|
|
|
|
_osd_handler_called: true
|
2021-06-15 00:01:41 +08:00
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Unset noup flag
|
2021-06-15 00:01:41 +08:00
|
|
|
ceph_osd_flag:
|
|
|
|
name: noup
|
|
|
|
cluster: "{{ cluster }}"
|
|
|
|
state: absent
|
|
|
|
environment:
|
|
|
|
CEPH_CONTAINER_IMAGE: "{{ ceph_docker_registry + '/' + ceph_docker_image + ':' + ceph_docker_image_tag if containerized_deployment | bool else None }}"
|
|
|
|
CEPH_CONTAINER_BINARY: "{{ container_binary }}"
|
|
|
|
delegate_to: "{{ groups[mon_group_name][0] }}"
|
|
|
|
run_once: true
|
|
|
|
|
|
|
|
# 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.
|
|
|
|
# This does not need to run during a rolling update as the playbook will
|
|
|
|
# restart all OSDs using the tasks "start ceph osd" or
|
|
|
|
# "restart containerized ceph osd"
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Copy osd restart script
|
|
|
|
ansible.builtin.template:
|
2021-06-15 00:01:41 +08:00
|
|
|
src: restart_osd_daemon.sh.j2
|
|
|
|
dest: "{{ tmpdirpath.path }}/restart_osd_daemon.sh"
|
|
|
|
owner: root
|
|
|
|
group: root
|
2024-02-14 18:14:02 +08:00
|
|
|
mode: "0750"
|
2021-12-30 22:08:08 +08:00
|
|
|
when: tmpdirpath.path is defined
|
2021-06-15 00:01:41 +08:00
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Get pool list
|
|
|
|
ansible.builtin.command: "{{ ceph_cmd }} --cluster {{ cluster }} osd pool ls detail -f json"
|
2021-06-15 00:01:41 +08:00
|
|
|
register: pool_list
|
|
|
|
delegate_to: "{{ groups.get(mon_group_name, [])[0] }}"
|
|
|
|
run_once: true
|
|
|
|
changed_when: false
|
2021-07-26 19:03:56 +08:00
|
|
|
check_mode: false
|
2021-06-15 00:01:41 +08:00
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Get balancer module status
|
|
|
|
ansible.builtin.command: "{{ ceph_cmd }} --cluster {{ cluster }} balancer status -f json"
|
2021-06-15 00:01:41 +08:00
|
|
|
register: balancer_status
|
|
|
|
run_once: true
|
|
|
|
delegate_to: "{{ groups[mon_group_name][0] }}"
|
|
|
|
changed_when: false
|
2021-07-26 19:03:56 +08:00
|
|
|
check_mode: false
|
2021-06-15 00:01:41 +08:00
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Set_fact pools_pgautoscaler_mode
|
|
|
|
ansible.builtin.set_fact:
|
2021-06-15 00:01:41 +08:00
|
|
|
pools_pgautoscaler_mode: "{{ pools_pgautoscaler_mode | default([]) | union([{'name': item.pool_name, 'mode': item.pg_autoscale_mode}]) }}"
|
|
|
|
run_once: true
|
2021-07-29 02:54:15 +08:00
|
|
|
with_items: "{{ pool_list.stdout | default('{}') | from_json }}"
|
2021-06-15 00:01:41 +08:00
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Disable balancer
|
|
|
|
ansible.builtin.command: "{{ ceph_cmd }} --cluster {{ cluster }} balancer off"
|
2021-06-15 00:01:41 +08:00
|
|
|
run_once: true
|
|
|
|
delegate_to: "{{ groups[mon_group_name][0] }}"
|
|
|
|
changed_when: false
|
|
|
|
when: (balancer_status.stdout | from_json)['active'] | bool
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Disable pg autoscale on pools
|
2021-06-15 00:01:41 +08:00
|
|
|
ceph_pool:
|
|
|
|
name: "{{ item.name }}"
|
|
|
|
cluster: "{{ cluster }}"
|
|
|
|
pg_autoscale_mode: false
|
|
|
|
with_items: "{{ pools_pgautoscaler_mode }}"
|
|
|
|
delegate_to: "{{ groups.get(mon_group_name, [])[0] }}"
|
|
|
|
run_once: true
|
|
|
|
when:
|
|
|
|
- pools_pgautoscaler_mode is defined
|
|
|
|
- item.mode == 'on'
|
|
|
|
environment:
|
|
|
|
CEPH_CONTAINER_IMAGE: "{{ ceph_docker_registry + '/' + ceph_docker_image + ':' + ceph_docker_image_tag if containerized_deployment | bool else None }}"
|
|
|
|
CEPH_CONTAINER_BINARY: "{{ container_binary }}"
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Restart ceph osds daemon(s)
|
|
|
|
ansible.builtin.command: /usr/bin/env bash {{ hostvars[item]['tmpdirpath']['path'] }}/restart_osd_daemon.sh
|
2021-06-15 00:01:41 +08:00
|
|
|
when:
|
|
|
|
- hostvars[item]['handler_osd_status'] | default(False) | bool
|
|
|
|
- handler_health_osd_check | bool
|
|
|
|
- hostvars[item]['_osd_handler_called'] | default(False) | bool
|
2021-12-30 22:08:08 +08:00
|
|
|
- hostvars[item].tmpdirpath.path is defined
|
2021-06-15 00:01:41 +08:00
|
|
|
with_items: "{{ groups[osd_group_name] | intersect(ansible_play_batch) }}"
|
|
|
|
delegate_to: "{{ item }}"
|
2024-02-14 18:14:02 +08:00
|
|
|
changed_when: false
|
|
|
|
run_once: true
|
2021-06-15 00:01:41 +08:00
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Set _osd_handler_called after restart
|
|
|
|
ansible.builtin.set_fact:
|
|
|
|
_osd_handler_called: false
|
2021-06-15 00:01:41 +08:00
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Re-enable pg autoscale on pools
|
2021-06-15 00:01:41 +08:00
|
|
|
ceph_pool:
|
|
|
|
name: "{{ item.name }}"
|
|
|
|
cluster: "{{ cluster }}"
|
|
|
|
pg_autoscale_mode: true
|
|
|
|
with_items: "{{ pools_pgautoscaler_mode }}"
|
|
|
|
run_once: true
|
|
|
|
delegate_to: "{{ groups.get(mon_group_name, [])[0] }}"
|
|
|
|
when:
|
|
|
|
- pools_pgautoscaler_mode is defined
|
|
|
|
- item.mode == 'on'
|
|
|
|
environment:
|
|
|
|
CEPH_CONTAINER_IMAGE: "{{ ceph_docker_registry + '/' + ceph_docker_image + ':' + ceph_docker_image_tag if containerized_deployment | bool else None }}"
|
|
|
|
CEPH_CONTAINER_BINARY: "{{ container_binary }}"
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Re-enable balancer
|
|
|
|
ansible.builtin.command: "{{ ceph_cmd }} --cluster {{ cluster }} balancer on"
|
2021-06-15 00:01:41 +08:00
|
|
|
run_once: true
|
|
|
|
delegate_to: "{{ groups[mon_group_name][0] }}"
|
|
|
|
changed_when: false
|
2021-12-30 22:08:08 +08:00
|
|
|
when: (balancer_status.stdout | from_json)['active'] | bool
|