deep_scrub_choked

This commit is contained in:
a.pivkin
2026-04-06 07:08:17 +03:00
commit 9149dc1d7f
840 changed files with 52471 additions and 0 deletions
+100
View File
@@ -0,0 +1,100 @@
---
- name: Create mgr directory
ansible.builtin.file:
path: /var/lib/ceph/mgr/{{ cluster }}-{{ ansible_facts['hostname'] }}
state: directory
owner: "{{ ceph_uid if containerized_deployment | bool else 'ceph' }}"
group: "{{ ceph_uid if containerized_deployment | bool else 'ceph' }}"
mode: "{{ ceph_directories_mode }}"
- name: Fetch ceph mgr keyring
ceph_key:
name: "mgr.{{ ansible_facts['hostname'] }}"
caps:
mon: allow profile mgr
osd: allow *
mds: allow *
cluster: "{{ cluster }}"
secret: "{{ (mgr_secret != 'mgr_secret') | ternary(mgr_secret, omit) }}"
owner: "{{ ceph_uid if containerized_deployment | bool else 'ceph' }}"
group: "{{ ceph_uid if containerized_deployment | bool else 'ceph' }}"
mode: "0400"
dest: "/var/lib/ceph/mgr/{{ cluster }}-{{ ansible_facts['hostname'] }}/keyring"
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 }}"
when: groups.get(mgr_group_name, []) | length == 0 # the key is present already since one of the mons created it in "create ceph mgr keyring(s)"
no_log: "{{ no_log_on_ceph_key_tasks }}"
- name: Create and copy keyrings
when: groups.get(mgr_group_name, []) | length > 0
block:
- name: Create ceph mgr keyring(s) on a mon node
ceph_key:
name: "mgr.{{ hostvars[item]['ansible_facts']['hostname'] }}"
caps:
mon: allow profile mgr
osd: allow *
mds: allow *
cluster: "{{ cluster }}"
secret: "{{ (mgr_secret != 'mgr_secret') | ternary(mgr_secret, omit) }}"
owner: "{{ ceph_uid if containerized_deployment | bool else 'ceph' }}"
group: "{{ ceph_uid if containerized_deployment | bool else 'ceph' }}"
mode: "0400"
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 }}"
with_items: "{{ groups.get(mgr_group_name, []) }}"
run_once: true
delegate_to: "{{ groups[mon_group_name][0] }}"
no_log: "{{ no_log_on_ceph_key_tasks }}"
- name: Set_fact _mgr_keys
ansible.builtin.set_fact:
_mgr_keys:
- { 'name': 'client.admin', 'path': "/etc/ceph/{{ cluster }}.client.admin.keyring", 'copy_key': "{{ copy_admin_key }}" }
- { 'name': "mgr.{{ ansible_facts['hostname'] }}", 'path': "/var/lib/ceph/mgr/{{ cluster }}-{{ ansible_facts['hostname'] }}/keyring", 'copy_key': true }
- name: Get keys from monitors
ceph_key_info:
name: "{{ item.name }}"
cluster: "{{ cluster }}"
output_format: plain
state: info
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 }}"
register: _mgr_keys
with_items: "{{ _mgr_keys }}"
delegate_to: "{{ groups[mon_group_name][0] if running_mon is undefined else running_mon }}"
when:
- cephx | bool
- item.copy_key | bool
no_log: "{{ no_log_on_ceph_key_tasks }}"
- name: Copy ceph key(s) if needed
ansible.builtin.copy:
dest: "{{ item.item.path }}"
content: "{{ item.stdout + '\n' }}"
owner: "{{ ceph_uid if containerized_deployment | bool else 'ceph' }}"
group: "{{ ceph_uid if containerized_deployment | bool else 'ceph' }}"
mode: "{{ ceph_keyring_permissions }}"
with_items: "{{ _mgr_keys.results }}"
when:
- cephx | bool
- item is not skipped
- item.item.copy_key | bool
no_log: "{{ no_log_on_ceph_key_tasks }}"
- name: Set mgr key permissions
ansible.builtin.file:
path: /var/lib/ceph/mgr/{{ cluster }}-{{ ansible_facts['hostname'] }}/keyring
owner: "{{ ceph_uid if containerized_deployment | bool else 'ceph' }}"
group: "{{ ceph_uid if containerized_deployment | bool else 'ceph' }}"
mode: "{{ ceph_keyring_permissions }}"
when: cephx | bool
- name: Append dashboard modules to ceph_mgr_modules
ansible.builtin.set_fact:
ceph_mgr_modules: "{{ ceph_mgr_modules | union(['dashboard', 'prometheus']) }}"
when: dashboard_enabled | bool
+26
View File
@@ -0,0 +1,26 @@
---
- name: Set_fact container_exec_cmd
ansible.builtin.set_fact:
container_exec_cmd: "{{ container_binary }} exec ceph-mon-{{ hostvars[item]['ansible_facts']['hostname'] }}"
with_items: "{{ groups.get(mon_group_name, []) }}"
delegate_to: "{{ item }}"
delegate_facts: true
run_once: true
when: containerized_deployment | bool
- name: Include common.yml
ansible.builtin.include_tasks: common.yml
- name: Include pre_requisite.yml
ansible.builtin.include_tasks: pre_requisite.yml
when: not containerized_deployment | bool
- name: Include start_mgr.yml
ansible.builtin.include_tasks: start_mgr.yml
- name: Include mgr_modules.yml
ansible.builtin.include_tasks: mgr_modules.yml
when:
- ceph_mgr_modules | length > 0
- ((groups[mgr_group_name] | default([]) | length == 0 and inventory_hostname == groups[mon_group_name] | last) or
(groups[mgr_group_name] | default([]) | length > 0 and inventory_hostname == groups[mgr_group_name] | last))
+51
View File
@@ -0,0 +1,51 @@
---
- name: Wait for all mgr to be up
ansible.builtin.command: "{{ hostvars[groups[mon_group_name][0]]['container_exec_cmd'] | default('') }} ceph --cluster {{ cluster }} mgr dump -f json"
register: mgr_dump
retries: 30
delay: 5
delegate_to: "{{ groups[mon_group_name][0] }}"
changed_when: false
until:
- mgr_dump.rc == 0
- (mgr_dump.stdout | from_json).available | bool
when: not ansible_check_mode
- name: Get enabled modules from ceph-mgr
ansible.builtin.command: "{{ hostvars[groups[mon_group_name][0]]['container_exec_cmd'] | default('') }} ceph --cluster {{ cluster }} --format json mgr module ls"
check_mode: false
changed_when: false
register: _ceph_mgr_modules
delegate_to: "{{ groups[mon_group_name][0] }}"
- name: Set _ceph_mgr_modules fact (convert _ceph_mgr_modules.stdout to a dict)
ansible.builtin.set_fact:
_ceph_mgr_modules: "{{ _ceph_mgr_modules.get('stdout', '{}') | from_json }}"
- name: Set _disabled_ceph_mgr_modules fact
ansible.builtin.set_fact:
_disabled_ceph_mgr_modules: "{% if _ceph_mgr_modules.disabled_modules | length == 0 %}[]{% elif _ceph_mgr_modules.disabled_modules[0] | type_debug != 'dict' %}{{ _ceph_mgr_modules['disabled_modules'] }}{% else %}{{ _ceph_mgr_modules['disabled_modules'] | map(attribute='name') | list }}{% endif %}"
- name: Disable ceph mgr enabled modules
ceph_mgr_module:
name: "{{ item }}"
cluster: "{{ cluster }}"
state: disable
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 }}"
with_items: "{{ _ceph_mgr_modules.get('enabled_modules', []) }}"
delegate_to: "{{ groups[mon_group_name][0] }}"
when: item not in ceph_mgr_modules
- name: Add modules to ceph-mgr
ceph_mgr_module:
name: "{{ item }}"
cluster: "{{ cluster }}"
state: enable
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 }}"
with_items: "{{ ceph_mgr_modules }}"
delegate_to: "{{ groups[mon_group_name][0] }}"
when: (item in _disabled_ceph_mgr_modules or _disabled_ceph_mgr_modules == [])
+45
View File
@@ -0,0 +1,45 @@
---
- name: Set_fact ceph_mgr_packages for sso
ansible.builtin.set_fact:
ceph_mgr_packages: "{{ ceph_mgr_packages | union(['python3-saml' if ansible_facts['distribution_major_version'] | int == 8 else 'python-saml']) }}"
when:
- dashboard_enabled | bool
- ansible_facts['distribution'] == 'RedHat'
- name: Set_fact ceph_mgr_packages for dashboard
ansible.builtin.set_fact:
ceph_mgr_packages: "{{ ceph_mgr_packages | union(['ceph-mgr-dashboard']) }}"
when: dashboard_enabled | bool
- name: Set_fact ceph_mgr_packages for non el7 distribution
ansible.builtin.set_fact:
ceph_mgr_packages: "{{ ceph_mgr_packages | union(['ceph-mgr-diskprediction-local']) }}"
when:
- ansible_facts['os_family'] != 'RedHat'
- ansible_facts['distribution_major_version'] | int != 7
- name: Enable crb repository
community.general.dnf_config_manager:
name: crb
state: enabled
when:
- ansible_facts['os_family'] == 'RedHat'
- ansible_facts['distribution_major_version'] | int == 9
- name: Install ceph-mgr packages on RedHat or SUSE
ansible.builtin.package:
name: '{{ ceph_mgr_packages }}'
state: "{{ (upgrade_ceph_packages | bool) | ternary('latest', 'present') }}"
register: result
until: result is succeeded
when: ansible_facts['os_family'] in ['RedHat', 'Suse']
- name: Install ceph-mgr packages for debian
ansible.builtin.apt:
name: '{{ ceph_mgr_packages }}'
state: "{{ (upgrade_ceph_packages | bool) | ternary('latest', 'present') }}"
default_release: "{{ ceph_stable_release_uca | default('') if ceph_origin == 'repository' and ceph_repository == 'uca' else ''}}{{ ansible_facts['distribution_release'] ~ '-backports' if ceph_origin == 'distro' and ceph_use_distro_backports | bool else '' }}"
register: result
until: result is succeeded
when: ansible_facts['os_family'] == 'Debian'
tags: package-install
+38
View File
@@ -0,0 +1,38 @@
---
- name: Ensure systemd service override directory exists
ansible.builtin.file:
state: directory
path: "/etc/systemd/system/ceph-mgr@.service.d/"
mode: "0755"
when:
- ceph_mgr_systemd_overrides is defined
- ansible_facts['service_mgr'] == 'systemd'
- name: Add ceph-mgr systemd service overrides
openstack.config_template.config_template:
src: "ceph-mgr.service.d-overrides.j2"
dest: "/etc/systemd/system/ceph-mgr@.service.d/ceph-mgr-systemd-overrides.conf"
config_overrides: "{{ ceph_mgr_systemd_overrides | default({}) }}"
config_type: "ini"
when:
- ceph_mgr_systemd_overrides is defined
- ansible_facts['service_mgr'] == 'systemd'
- name: Include_tasks systemd.yml
ansible.builtin.include_tasks: systemd.yml
when: containerized_deployment | bool
- name: Enable ceph-mgr.target
ansible.builtin.service:
name: ceph-mgr.target
enabled: true
daemon_reload: true
when: containerized_deployment | bool
- name: Systemd start mgr
ansible.builtin.systemd:
name: ceph-mgr@{{ ansible_facts['hostname'] }}
state: started
enabled: true
masked: false
daemon_reload: true
+16
View File
@@ -0,0 +1,16 @@
---
- name: Generate systemd unit file
ansible.builtin.template:
src: "{{ role_path }}/templates/ceph-mgr.service.j2"
dest: /etc/systemd/system/ceph-mgr@.service
owner: "root"
group: "root"
mode: "0644"
notify: Restart ceph mgrs
- name: Generate systemd ceph-mgr target file
ansible.builtin.copy:
src: ceph-mgr.target
dest: /etc/systemd/system/ceph-mgr.target
mode: "0644"
when: containerized_deployment | bool