# - "{{ crush_rule_hdd }}"
# - "{{ crush_rule_ssd }}"
-# Caution: this will create crush roots and racks according to {{ osd_crush_location }}
+# 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
+
#############
# OPENSTACK #
#############
- "{{ crush_rule_hdd }}"
- "{{ crush_rule_ssd }}"
-# Caution: this will create crush roots and racks according to {{ osd_crush_location }}
+# 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
+
#############
# OPENSTACK #
#############
---
-- name: create roots needed for configured crush rules
- command: "{{ docker_exec_cmd }} ceph --cluster {{ cluster }} osd crush add-bucket {{ item.root }} root"
- with_items: "{{ crush_rules | unique }}"
- changed_when: false
- failed_when: false
- run_once: true
- when: create_crush_tree
-
-- name: create rack type buckets needed for configured crush rules
- command: "{{ docker_exec_cmd }} ceph --cluster {{ cluster }} osd crush add-bucket {{ hostvars[item]['ceph_crush_rack']|default('default_rack_' + hostvars[item]['ceph_crush_root']) }} rack"
- with_items: "{{ groups[osd_group_name] }}"
- changed_when: false
- failed_when: false
- run_once: true
- when: create_crush_tree
-
-- name: move rack type buckets to created corresponding crush roots
- command: "{{ docker_exec_cmd }} ceph --cluster {{ cluster }} osd crush move {{ hostvars[item]['ceph_crush_rack']|default('default_rack_' + hostvars[item]['ceph_crush_root']) }} root={{ hostvars[item]['ceph_crush_root'] }}"
- with_items: "{{ groups[osd_group_name] }}"
- changed_when: false
- failed_when: false
+- name: configure crush hierarchy
+ ceph_crush:
+ cluster: "{{ cluster }}"
+ location: "{{ hostvars[item]['osd_crush_location'] }}"
+ containerized: "{{ docker_exec_cmd }}"
run_once: true
- when: create_crush_tree
-
-- name: move host type buckets to rack type ones
- command: "{{ docker_exec_cmd }} ceph --cluster {{ cluster }} osd crush move {{ hostvars[item]['ansible_hostname'] }} rack={{ hostvars[item]['ceph_crush_rack']|default('default_rack_' + hostvars[item]['ceph_crush_root']) }}"
with_items: "{{ groups[osd_group_name] }}"
- changed_when: false
- failed_when: false
- run_once: true
- when: create_crush_tree
+ when:
+ - create_crush_tree
+ - hostvars[item]['osd_crush_location'] is defined
- name: create configured crush rules
command: "{{ docker_exec_cmd }} ceph --cluster {{ cluster }} osd crush rule create-simple {{ item.name }} {{ item.root }} {{ item.type }}"
with_items: "{{ crush_rules | unique }}"
changed_when: false
- failed_when: false
run_once: true
- name: get id for new default crush rule
command: "{{ docker_exec_cmd }} ceph --cluster {{ cluster }} osd -f json crush rule dump {{ item.name }}"
register: info_ceph_default_crush_rule
changed_when: false
- failed_when: false
with_items: "{{ crush_rules }}"
when: item.default
# If multiple rules are set as default (should not be) then the last one is taken as actual default.
+# NOTE(leseb): we should actually fail if multiple rules are set as default
- name: set_fact info_ceph_default_crush_rule_yaml
set_fact:
info_ceph_default_crush_rule_yaml: "{{ item.stdout|from_json() }}"
- name: insert new default crush rule into daemon to prevent restart
command: "{{ docker_exec_cmd }} ceph --cluster {{ cluster }} daemon mon.{{ monitor_name }} config set osd_pool_default_crush_replicated_ruleset {{ info_ceph_default_crush_rule_yaml.rule_id }}"
changed_when: false
- failed_when: false
when: info_ceph_default_crush_rule_yaml|default('')|length > 0
- name: add new default crush rule to ceph.conf
option: "osd pool default crush replicated ruleset"
value: "{{ info_ceph_default_crush_rule_yaml.rule_id }}"
when: info_ceph_default_crush_rule_yaml|default('')|length > 0
-