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
+201
View File
@@ -0,0 +1,201 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [2014] [Sébastien Han]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
+3
View File
@@ -0,0 +1,3 @@
# Ansible role: ceph-osd
Documentation is available at http://docs.ceph.com/ceph-ansible/.
+218
View File
@@ -0,0 +1,218 @@
---
###########
# GENERAL #
###########
# Even though OSD nodes should not have the admin key
# at their disposal, some people might want to have it
# distributed on OSD nodes. Setting 'copy_admin_key' to 'true'
# will copy the admin key to the /etc/ceph/ directory
copy_admin_key: false
##############
# CEPH OPTIONS
##############
# Devices to be used as OSDs
# You can pre-provision disks that are not present yet.
# Ansible will just skip them. Newly added disk will be
# automatically configured during the next run.
#
# Declare devices to be used as OSDs
# All scenario(except 3rd) inherit from the following device declaration
# Note: This scenario uses the ceph-volume lvm batch method to provision OSDs
# devices:
# - /dev/sdb
# - /dev/sdc
# - /dev/sdd
# - /dev/sde
devices: []
# Declare devices to be used as block.db devices
# dedicated_devices:
# - /dev/sdx
# - /dev/sdy
dedicated_devices: []
# Declare devices to be used as block.wal devices
# bluestore_wal_devices:
# - /dev/nvme0n1
# - /dev/nvme0n2
bluestore_wal_devices: []
# 'osd_auto_discovery' mode prevents you from filling out the 'devices' variable above.
# Device discovery is based on the Ansible fact 'ansible_facts["devices"]'
# which reports all the devices on a system. If chosen, all the disks
# found will be passed to ceph-volume lvm batch. You should not be worried on using
# this option since ceph-volume has a built-in check which looks for empty devices.
# Thus devices with existing partition tables will not be used.
#
osd_auto_discovery: false
# Encrypt your OSD device using dmcrypt
# If set to True, no matter which osd_objecstore you use the data will be encrypted
dmcrypt: false
# Use ceph-volume to create OSDs from logical volumes.
# lvm_volumes is a list of dictionaries.
#
# Filestore: Each dictionary must contain a data, journal and vg_name key. Any
# logical volume or logical group used must be a name and not a path. data
# can be a logical volume, device or partition. journal can be either a lv or partition.
# You can not use the same journal for many data lvs.
# data_vg must be the volume group name of the data lv, only applicable when data is an lv.
# journal_vg is optional and must be the volume group name of the journal lv, if applicable.
# For example:
# lvm_volumes:
# - data: data-lv1
# data_vg: vg1
# journal: journal-lv1
# journal_vg: vg2
# crush_device_class: foo
# - data: data-lv2
# journal: /dev/sda1
# data_vg: vg1
# - data: data-lv3
# journal: /dev/sdb1
# data_vg: vg2
# - data: /dev/sda
# journal: /dev/sdb1
# - data: /dev/sda1
# journal: /dev/sdb1
#
# Bluestore: Each dictionary must contain at least data. When defining wal or
# db, it must have both the lv name and vg group (db and wal are not required).
# This allows for four combinations: just data, data and wal, data and wal and
# db, data and db.
# For example:
# lvm_volumes:
# - data: data-lv1
# data_vg: vg1
# wal: wal-lv1
# wal_vg: vg1
# crush_device_class: foo
# - data: data-lv2
# db: db-lv2
# db_vg: vg2
# - data: data-lv3
# wal: wal-lv1
# wal_vg: vg3
# db: db-lv3
# db_vg: vg3
# - data: data-lv4
# data_vg: vg4
# - data: /dev/sda
# - data: /dev/sdb1
lvm_volumes: []
crush_device_class: ""
osds_per_device: 1
###############
# CRUSH RULES #
###############
crush_rule_config: false
crush_rule_hdd:
name: HDD
root: default
type: host
class: hdd
default: false
crush_rule_ssd:
name: SSD
root: default
type: host
class: ssd
default: false
crush_rules:
- "{{ crush_rule_hdd }}"
- "{{ crush_rule_ssd }}"
ceph_ec_profiles: {}
# Caution: this will create crush roots and racks according to hostvars {{ osd_crush_location }}
# and will move hosts into them which might lead to significant data movement in the cluster!
#
# In order for the playbook to create CRUSH hierarchy, you have to setup your Ansible inventory file like so:
#
# [osds]
# ceph-osd-01 osd_crush_location="{ 'root': 'mon-roottt', 'rack': 'mon-rackkkk', 'pod': 'monpod', 'host': 'ceph-osd-01' }"
#
# Note that 'host' is mandatory and that you need to submit at least two bucket type (including the host)
create_crush_tree: false
##########
# DOCKER #
##########
ceph_config_keys: [] # DON'T TOUCH ME
# Resource limitation
# For the whole list of limits you can apply see: docs.docker.com/engine/admin/resource_constraints
# Default values are based from: https://access.redhat.com/documentation/en-us/red_hat_ceph_storage/2/html/red_hat_ceph_storage_hardware_guide/minimum_recommendations
ceph_osd_docker_memory_limit: "{{ ansible_facts['memtotal_mb'] }}m"
ceph_osd_docker_cpu_limit: 4
# The next two variables are undefined, and thus, unused by default.
# If `lscpu | grep NUMA` returned the following:
# NUMA node0 CPU(s): 0,2,4,6,8,10,12,14,16
# NUMA node1 CPU(s): 1,3,5,7,9,11,13,15,17
# then, the following would run the OSD on the first NUMA node only.
# ceph_osd_docker_cpuset_cpus: "0,2,4,6,8,10,12,14,16"
# ceph_osd_docker_cpuset_mems: "0"
# PREPARE DEVICE
#
# WARNING /!\ DMCRYPT scenario ONLY works with Docker version 1.12.5 and above
#
ceph_osd_docker_devices: "{{ devices }}"
ceph_osd_docker_prepare_env: -e OSD_JOURNAL_SIZE={{ journal_size }}
# ACTIVATE DEVICE
#
ceph_osd_numactl_opts: ""
# If you want to add parameters, you should retain the existing ones and include the new ones.
ceph_osd_container_params:
volumes:
- /dev:/dev
- /var/lib/ceph/bootstrap-osd/ceph.keyring:/var/lib/ceph/bootstrap-osd/ceph.keyring:z
- /var/lib/ceph/osd/{{ cluster }}-"${OSD_ID}":/var/lib/ceph/osd/{{ cluster }}-"${OSD_ID}":z
- /var/run/udev/:/var/run/udev/
- /run/lvm/:/run/lvm/
envs:
OSD_ID: ${OSD_ID}
args:
- -f
- -i=${OSD_ID}
###########
# SYSTEMD #
###########
# ceph_osd_systemd_overrides will override the systemd settings
# for the ceph-osd services.
# For example,to set "PrivateDevices=false" you can specify:
# ceph_osd_systemd_overrides:
# Service:
# PrivateDevices: false
###########
# CHECK #
###########
nb_retry_wait_osd_up: 60
delay_wait_osd_up: 10
+9
View File
@@ -0,0 +1,9 @@
[Unit]
Description=ceph target allowing to start/stop all ceph-osd@.service instances at once
PartOf=ceph.target
After=ceph-mon.target
Before=ceph.target
Wants=ceph.target ceph-mon.target
[Install]
WantedBy=multi-user.target ceph.target
+14
View File
@@ -0,0 +1,14 @@
---
galaxy_info:
company: Red Hat
author: Sébastien Han
description: Installs Ceph Object Storage Daemon
license: Apache
min_ansible_version: '2.7'
platforms:
- name: EL
versions:
- 'all'
galaxy_tags:
- system
dependencies: []
+46
View File
@@ -0,0 +1,46 @@
---
- name: Create bootstrap-osd and osd directories
ansible.builtin.file:
path: "{{ item }}"
state: directory
owner: "{{ ceph_uid if containerized_deployment | bool else 'ceph' }}"
group: "{{ ceph_uid if containerized_deployment | bool else 'ceph' }}"
mode: "{{ ceph_directories_mode }}"
when: cephx | bool
with_items:
- /var/lib/ceph/bootstrap-osd/
- /var/lib/ceph/osd/
- 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: _osd_keys
with_items:
- { name: "client.bootstrap-osd", path: "/var/lib/ceph/bootstrap-osd/{{ cluster }}.keyring", copy_key: true }
- { name: "client.admin", path: "/etc/ceph/{{ cluster }}.client.admin.keyring", copy_key: "{{ copy_admin_key }}" }
delegate_to: "{{ groups.get(mon_group_name)[0] }}"
run_once: true
no_log: "{{ no_log_on_ceph_key_tasks }}"
when:
- cephx | bool
- item.copy_key | bool
- 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: "{{ _osd_keys.results }}"
when:
- cephx | bool
- item is not skipped
- item.item.copy_key | bool
no_log: "{{ no_log_on_ceph_key_tasks }}"
+98
View File
@@ -0,0 +1,98 @@
---
- name: Configure crush hierarchy
ceph_crush:
cluster: "{{ cluster }}"
location: "{{ osd_crush_location }}"
containerized: "{{ hostvars[groups[mon_group_name][0]]['container_exec_cmd'] | default('') }}"
register: config_crush_hierarchy
delegate_to: '{{ groups[mon_group_name][0] }}'
when:
- hostvars[groups[mon_group_name][0]]['create_crush_tree'] | default(create_crush_tree) | bool
- osd_crush_location is defined
- name: Create configured ec profiles
ceph_ec_profile:
name: "{{ item.key }}"
cluster: "{{ cluster }}"
state: "{{ item.value.state | default('present') }}"
stripe_unit: "{{ item.value.stripe_unit | default(omit) }}"
plugin: "{{ item.value.plugin | default(omit) }}"
k: "{{ item.value.k }}"
m: "{{ item.value.m }}"
d: "{{ item.value.d | default(omit) }}"
l: "{{ item.value.l | default(omit) }}"
c: "{{ item.value.c | default(omit) }}"
scalar_mds: "{{ item.value.scalar_mds | default(omit) }}"
technique: "{{ item.value.technique | default(omit) }}"
crush_root: "{{ item.value.crush_root | default(omit) }}"
crush_failure_domain: "{{ item.value.crush_failure_domain | default(omit) }}"
crush_device_class: "{{ item.value.crush_device_class | default(omit) }}"
force: "{{ item.value.force | default(false) }}"
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 }}"
loop: "{{ ceph_ec_profiles | dict2items }}"
delegate_to: '{{ groups[mon_group_name][0] }}'
run_once: true
- name: Create configured crush rules
ceph_crush_rule:
name: "{{ item.name }}"
cluster: "{{ cluster }}"
rule_type: "{{ item.rule_type | default('replicated') }}"
profile: "{{ item.ec_profile | default(omit) }}"
bucket_root: "{{ item.root | default(omit) }}"
bucket_type: "{{ item.type | default(omit) }}"
device_class: "{{ item.class | default(omit) }}"
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: "{{ hostvars[groups[mon_group_name][0]]['crush_rules'] | default(crush_rules) | unique }}"
delegate_to: '{{ groups[mon_group_name][0] }}'
run_once: true
- name: Get id for new default crush rule
ceph_crush_rule_info:
name: "{{ item.name }}"
cluster: "{{ cluster }}"
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: info_ceph_default_crush_rule
with_items: "{{ hostvars[groups[mon_group_name][0]]['crush_rules'] | default(crush_rules) | unique }}"
delegate_to: '{{ groups[mon_group_name][0] }}'
run_once: true
when: item.default | default(False) | bool
# If multiple rules are set as default (should not be) then the last one is taken as actual default.
# the with_items statement overrides each iteration with the new one.
# NOTE(leseb): we should actually fail if multiple rules are set as default
- name: Set_fact info_ceph_default_crush_rule_yaml, ceph_osd_pool_default_crush_rule_name
ansible.builtin.set_fact:
info_ceph_default_crush_rule_yaml: "{{ item.stdout | default('{}', True) | from_json() }}"
ceph_osd_pool_default_crush_rule_name: "{{ (item.stdout | default('{}', True) | from_json).get('rule_name') }}"
with_items: "{{ info_ceph_default_crush_rule.results }}"
run_once: true
when: not item.get('skipped', false)
- name: Insert new default crush rule into daemon to prevent restart
ansible.builtin.command: "{{ hostvars[item]['container_exec_cmd'] | default('') }} ceph --admin-daemon /var/run/ceph/{{ cluster }}-mon.{{ hostvars[item]['monitor_name'] }}.asok config set osd_pool_default_crush_rule {{ info_ceph_default_crush_rule_yaml.rule_id }}"
changed_when: false
delegate_to: "{{ item }}"
with_items: "{{ groups[mon_group_name] }}"
run_once: true
when:
- info_ceph_default_crush_rule_yaml | default('') | length > 0
- name: Add new default crush rule to ceph config file
community.general.ini_file:
dest: "/etc/ceph/{{ cluster }}.conf"
section: "global"
option: "osd_pool_default_crush_rule"
value: "{{ info_ceph_default_crush_rule_yaml.rule_id }}"
mode: "0644"
delegate_to: "{{ item }}"
with_items: "{{ groups[mon_group_name] }}"
run_once: true
when:
- info_ceph_default_crush_rule_yaml | default('') | length > 0
+101
View File
@@ -0,0 +1,101 @@
---
- name: Set_fact add_osd
ansible.builtin.set_fact:
add_osd: "{{ groups[osd_group_name] | length != ansible_play_hosts_all | length }}"
- 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_tasks system_tuning.yml
ansible.builtin.include_tasks: system_tuning.yml
- name: Install dependencies
ansible.builtin.package:
name: parted
state: present
register: result
until: result is succeeded
when:
- not containerized_deployment | bool
- ansible_facts['os_family'] != 'ClearLinux'
- name: Install numactl when needed
ansible.builtin.package:
name: numactl
register: result
until: result is succeeded
when:
- containerized_deployment | bool
- ceph_osd_numactl_opts | length > 0
tags: with_pkg
- name: Include_tasks common.yml
ansible.builtin.include_tasks: common.yml
- name: Set noup flag
ceph_osd_flag:
name: noup
cluster: "{{ cluster }}"
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
when:
- not rolling_update | default(False) | bool
- not switch_to_containers | default(False) | bool
- name: Include_tasks scenarios/lvm.yml
ansible.builtin.include_tasks: scenarios/lvm.yml
when:
- lvm_volumes|length > 0
- not rolling_update|default(False) | bool
- name: Include_tasks scenarios/lvm-batch.yml
ansible.builtin.include_tasks: scenarios/lvm-batch.yml
when:
- devices|length > 0
- not rolling_update|default(False) | bool
- name: Include_tasks start_osds.yml
ansible.builtin.include_tasks: start_osds.yml
- name: Unset noup flag
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] }}"
when:
- not rolling_update | default(False) | bool
- not switch_to_containers | default(False) | bool
- inventory_hostname == ansible_play_hosts_all | last
- name: Wait for all osd to be up
ansible.builtin.command: "{{ hostvars[groups[mon_group_name][0]]['container_exec_cmd'] | default('') }} ceph --cluster {{ cluster }} osd stat -f json"
register: wait_for_all_osds_up
retries: "{{ nb_retry_wait_osd_up }}"
delay: "{{ delay_wait_osd_up }}"
changed_when: false
delegate_to: "{{ groups[mon_group_name][0] }}"
until:
- (wait_for_all_osds_up.stdout | from_json)["num_osds"] | int > 0
- (wait_for_all_osds_up.stdout | from_json)["num_osds"] == (wait_for_all_osds_up.stdout | from_json)["num_up_osds"]
when:
- not ansible_check_mode
- inventory_hostname == ansible_play_hosts_all | last
tags: wait_all_osds_up
- name: Include crush_rules.yml
ansible.builtin.include_tasks: crush_rules.yml
when: hostvars[groups[mon_group_name][0]]['crush_rule_config'] | default(crush_rule_config) | bool
tags: wait_all_osds_up
@@ -0,0 +1,21 @@
---
- name: Use ceph-volume lvm batch to create osds
ceph_volume:
cluster: "{{ cluster }}"
objectstore: "{{ osd_objectstore }}"
batch_devices: "{{ _devices }}"
dmcrypt: "{{ dmcrypt | default(omit) }}"
crush_device_class: "{{ crush_device_class | default(omit) }}"
osds_per_device: "{{ osds_per_device }}"
block_db_size: "{{ block_db_size }}"
block_db_devices: "{{ dedicated_devices | unique if dedicated_devices | length > 0 else omit }}"
wal_devices: "{{ bluestore_wal_devices | unique if bluestore_wal_devices | length > 0 else omit }}"
action: "batch"
environment:
CEPH_VOLUME_DEBUG: "{{ ceph_volume_debug }}"
CEPH_CONTAINER_IMAGE: "{{ ceph_docker_registry + '/' + ceph_docker_image + ':' + ceph_docker_image_tag if containerized_deployment | bool else None }}"
CEPH_CONTAINER_BINARY: "{{ container_binary }}"
PYTHONIOENCODING: utf-8
when: _devices | default([]) | length > 0
tags: prepare_osd
+21
View File
@@ -0,0 +1,21 @@
---
- name: Use ceph-volume to create osds
ceph_volume:
cluster: "{{ cluster }}"
objectstore: "{{ osd_objectstore }}"
data: "{{ item.data }}"
data_vg: "{{ item.data_vg | default(omit) }}"
db: "{{ item.db | default(omit) }}"
db_vg: "{{ item.db_vg | default(omit) }}"
wal: "{{ item.wal | default(omit) }}"
wal_vg: "{{ item.wal_vg | default(omit) }}"
crush_device_class: "{{ item.crush_device_class | default(crush_device_class) | default(omit) }}"
dmcrypt: "{{ dmcrypt | default(omit) }}"
action: "{{ 'prepare' if containerized_deployment | bool else 'create' }}"
environment:
CEPH_VOLUME_DEBUG: "{{ ceph_volume_debug }}"
CEPH_CONTAINER_IMAGE: "{{ ceph_docker_registry + '/' + ceph_docker_image + ':' + ceph_docker_image_tag if containerized_deployment | bool else None }}"
CEPH_CONTAINER_BINARY: "{{ container_binary }}"
PYTHONIOENCODING: utf-8
with_items: "{{ lvm_volumes }}"
tags: prepare_osd
+69
View File
@@ -0,0 +1,69 @@
---
# this is for ceph-disk, the ceph-disk command is gone so we have to list /var/lib/ceph
- name: Get osd ids
ansible.builtin.shell: ls /var/lib/ceph/osd/ | sed 's/.*-//' # noqa risky-shell-pipe
args:
executable: /bin/bash
changed_when: false
failed_when: false
register: osd_ids_non_container
- name: Collect osd ids
ceph_volume:
cluster: "{{ cluster }}"
action: list
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: ceph_osd_ids
- name: Include_tasks systemd.yml
ansible.builtin.include_tasks: systemd.yml
when: containerized_deployment | bool
- name: Ensure systemd service override directory exists
ansible.builtin.file:
state: directory
path: "/etc/systemd/system/ceph-osd@.service.d/"
mode: "0755"
when:
- ceph_osd_systemd_overrides is defined
- ansible_facts['service_mgr'] == 'systemd'
- name: Add ceph-osd systemd service overrides
openstack.config_template.config_template:
src: "ceph-osd.service.d-overrides.j2"
dest: "/etc/systemd/system/ceph-osd@.service.d/ceph-osd-systemd-overrides.conf"
config_overrides: "{{ ceph_osd_systemd_overrides | default({}) }}"
config_type: "ini"
when:
- ceph_osd_systemd_overrides is defined
- ansible_facts['service_mgr'] == 'systemd'
- name: Ensure /var/lib/ceph/osd/<cluster>-<item> is present
ansible.builtin.file:
state: directory
path: "/var/lib/ceph/osd/{{ cluster }}-{{ item }}"
mode: "{{ ceph_directories_mode }}"
owner: "{{ ceph_uid if containerized_deployment | bool else 'ceph' }}"
group: "{{ ceph_uid if containerized_deployment | bool else 'ceph' }}"
with_items: "{{ ((ceph_osd_ids.stdout | default('{}', True) | from_json).keys() | list) | union(osd_ids_non_container.stdout_lines | default([])) }}"
- name: Write run file in /var/lib/ceph/osd/xxxx/run
ansible.builtin.template:
src: systemd-run.j2
dest: "/var/lib/ceph/osd/{{ cluster }}-{{ item }}/run"
mode: "0700"
owner: "{{ ceph_uid if containerized_deployment | bool else 'ceph' }}"
group: "{{ ceph_uid if containerized_deployment | bool else 'ceph' }}"
with_items: "{{ ((ceph_osd_ids.stdout | default('{}', True) | from_json).keys() | list) | union(osd_ids_non_container.stdout_lines | default([])) }}"
when: containerized_deployment | bool
- name: Systemd start osd
ansible.builtin.systemd:
name: ceph-osd@{{ item }}
state: started
enabled: true
masked: false
daemon_reload: true
with_items: "{{ ((ceph_osd_ids.stdout | default('{}', True) | from_json).keys() | list) | union(osd_ids_non_container.stdout_lines | default([])) }}"
+43
View File
@@ -0,0 +1,43 @@
---
- name: Create tmpfiles.d directory
ansible.builtin.file:
path: "/etc/tmpfiles.d"
state: "directory"
owner: "root"
group: "root"
mode: "0755"
register: "tmpfiles_d"
when: disable_transparent_hugepage | bool
- name: Disable transparent hugepage
ansible.builtin.template:
src: "tmpfiles_hugepage.j2"
dest: "/etc/tmpfiles.d/ceph_transparent_hugepage.conf"
group: "root"
owner: "root"
mode: "0644"
force: "yes"
validate: "systemd-tmpfiles --create %s"
when: disable_transparent_hugepage | bool
- name: Get default vm.min_free_kbytes
ansible.builtin.slurp:
src: /proc/sys/vm/min_free_kbytes
register: default_vm_min_free_kbytes
- name: Set_fact vm_min_free_kbytes
ansible.builtin.set_fact:
vm_min_free_kbytes: "{{ 4194303 if ansible_facts['memtotal_mb'] >= 49152 else default_vm_min_free_kbytes.content | b64decode | trim }}"
- name: Apply operating system tuning
ansible.posix.sysctl:
name: "{{ item.name }}"
value: "{{ item.value }}"
state: present
sysctl_file: /etc/sysctl.d/ceph-tuning.conf
sysctl_set: true
ignoreerrors: true
with_items:
- { name: "fs.aio-max-nr", value: "1048576", enable: "{{ osd_objectstore == 'bluestore' }}" }
- "{{ os_tuning_params }}"
when: item.enable | default(true) | bool
+23
View File
@@ -0,0 +1,23 @@
---
- name: Generate systemd unit file
ansible.builtin.template:
src: "{{ role_path }}/templates/ceph-osd.service.j2"
dest: /etc/systemd/system/ceph-osd@.service
owner: "root"
group: "root"
mode: "0644"
notify: Restart ceph osds
- name: Generate systemd ceph-osd target file
ansible.builtin.copy:
src: ceph-osd.target
dest: /etc/systemd/system/ceph-osd.target
mode: "0644"
when: containerized_deployment | bool
- name: Enable ceph-osd.target
ansible.builtin.service:
name: ceph-osd.target
enabled: true
daemon_reload: true
when: containerized_deployment | bool
@@ -0,0 +1 @@
# {{ ansible_managed }}
@@ -0,0 +1,42 @@
# {{ ansible_managed }}
[Unit]
Description=Ceph OSD
PartOf=ceph-osd.target
{% if container_binary == 'docker' %}
After=docker.service network-online.target local-fs.target time-sync.target
Requires=docker.service
{% else %}
After=network-online.target local-fs.target time-sync.target
{% endif %}
Wants=network-online.target local-fs.target time-sync.target
{% set cpu_limit = ansible_facts['processor_vcpus']|int if ceph_osd_docker_cpu_limit|int > ansible_facts['processor_vcpus']|int else ceph_osd_docker_cpu_limit|int %}
[Service]
EnvironmentFile=-/etc/environment
{% if container_binary == 'podman' %}
ExecStartPre=-/usr/bin/rm -f /%t/%n-pid /%t/%n-cid
ExecStartPre=-/usr/bin/{{ container_binary }} rm --storage ceph-osd-%i
ExecStartPre=-/usr/bin/mkdir -p /var/log/ceph
ExecStartPre=-/usr/bin/mkdir -p /var/lib/ceph/osd/{{ cluster }}-%i
{% else %}
ExecStartPre=-/usr/bin/{{ container_binary }} stop ceph-osd-%i
{% endif %}
ExecStartPre=-/usr/bin/{{ container_binary }} rm -f ceph-osd-%i
ExecStart=/bin/bash /var/lib/ceph/osd/{{ cluster }}-%i/run %t %n
{% if container_binary == 'podman' %}
ExecStop=-/usr/bin/sh -c "/usr/bin/{{ container_binary }} rm -f `cat /%t/%n-cid`"
{% else %}
ExecStop=-/usr/bin/{{ container_binary }} stop --timeout 120 ceph-osd-%i
{% endif %}
KillMode=none
Restart=always
RestartSec=10s
TimeoutStartSec=120
TimeoutStopSec=120
{% if container_binary == 'podman' %}
Type=forking
PIDFile=/%t/%n-pid
{% endif %}
[Install]
WantedBy=ceph.target
+58
View File
@@ -0,0 +1,58 @@
#!/bin/sh
{% set cpu_limit = ansible_facts['processor_vcpus']|int if ceph_osd_docker_cpu_limit|int > ansible_facts['processor_vcpus']|int else ceph_osd_docker_cpu_limit|int %}
OSD_ID={{ item }}
T=$1
N=$2
CEPH_VOLUME_CMD="/usr/bin/{{ container_binary }} run --rm --net=host --privileged=true --pid=host --ipc=host -v /dev:/dev -v /etc/localtime:/etc/localtime:ro -v /var/lib/ceph/osd/{{ cluster }}-${OSD_ID}:/var/lib/ceph/osd/{{ cluster }}-${OSD_ID}:z -v /etc/ceph:/etc/ceph:z -v /var/run/ceph:/var/run/ceph:z -v /var/run/udev/:/var/run/udev/ -v /var/log/ceph:/var/log/ceph:z -v /run/lvm/:/run/lvm/ --entrypoint=ceph-volume {{ ceph_docker_registry }}/{{ ceph_docker_image }}:{{ ceph_docker_image_tag }}"
PYTHON=python3
CEPH_VOLUME_LIST_JSON="$($CEPH_VOLUME_CMD lvm list --format json)"
# Find the OSD FSID from the OSD ID
OSD_FSID="$(echo "$CEPH_VOLUME_LIST_JSON" | $PYTHON -c "import sys, json; print(json.load(sys.stdin)['$OSD_ID'][0]['tags']['ceph.osd_fsid'])")"
# Find the OSD type
OSD_TYPE="$(echo "$CEPH_VOLUME_LIST_JSON" | $PYTHON -c "import sys, json; print(json.load(sys.stdin)['$OSD_ID'][0]['type'])")"
# Discover the objectstore
if [[ "block wal db" =~ $OSD_TYPE ]]; then
OSD_OBJECTSTORE=(--bluestore)
else
log "Unable to discover osd objectstore for OSD type: $OSD_TYPE"
exit 1
fi
# activate
$CEPH_VOLUME_CMD lvm activate --no-systemd ${OSD_OBJECTSTORE[@]} ${OSD_ID} ${OSD_FSID}
# start ceph-osd
{% if ceph_osd_numactl_opts != "" %}
numactl \
{{ ceph_osd_numactl_opts }} \
{% endif %}
/usr/bin/{{ container_binary }} run \
{% if container_binary == 'podman' %}
-d --log-driver journald --conmon-pidfile /${T}/${N}-pid --cidfile /${T}/${N}-cid \
{% endif %}
--pids-limit={{ 0 if container_binary == 'podman' else -1 }} \
--rm --net=host --privileged=true --pid=host \
--ipc=host \
--cpus={{ cpu_limit }} \
{% if ceph_osd_docker_cpuset_cpus is defined -%}
--cpuset-cpus='{{ ceph_osd_docker_cpuset_cpus }}' \
{% endif -%}
{% if ceph_osd_docker_cpuset_mems is defined -%}
--cpuset-mems='{{ ceph_osd_docker_cpuset_mems }}' \
{% endif -%}
{% for v in ceph_common_container_params['volumes'] + ceph_osd_container_params['volumes'] | default([]) %}
-v {{ v }} \
{% endfor %}
{% if ansible_facts['distribution'] == 'Ubuntu' -%}
--security-opt apparmor=unconfined \
{% endif -%}
{% for k, v in (ceph_common_container_params['envs'] | combine(ceph_osd_container_params['envs'] | default({}))).items() %}
-e {{ k }}={{ v }} \
{% endfor %}
--name=ceph-osd-${OSD_ID} \
--entrypoint=/usr/bin/ceph-osd \
{{ ceph_docker_registry }}/{{ ceph_docker_image }}:{{ ceph_docker_image_tag }} \
{{ (ceph_common_container_params['args'] + ceph_osd_container_params['args'] | default([])) | join(' ') }}
@@ -0,0 +1,3 @@
{{ '# ' + ansible_managed }}
{{ 'w /sys/kernel/mm/transparent_hugepage/enabled - - - - never' }}
+2
View File
@@ -0,0 +1,2 @@
---
container_bin_path: /opt/ceph-container/bin