]> git.apps.os.sepia.ceph.com Git - ceph-ansible.git/commitdiff
mon: use ceph_crush module in the playbook
authorSébastien Han <seb@redhat.com>
Wed, 21 Feb 2018 14:20:24 +0000 (15:20 +0100)
committerGuillaume Abrioux <gabrioux@redhat.com>
Tue, 6 Mar 2018 15:24:31 +0000 (15:24 +0000)
Instead of creating the CRUSH hierarchy with Ansible tasks using the
command module we now rely on the ceph_crush module.

Signed-off-by: Sébastien Han <seb@redhat.com>
group_vars/mons.yml.sample
roles/ceph-mon/defaults/main.yml
roles/ceph-mon/tasks/crush_rules.yml

index 617f7814b3e9cb1e030faabf9a2afc2dfa736b3e..3b7e5f1044ce3a1c0047d254409fe6d459a29c4f 100644 (file)
@@ -70,10 +70,18 @@ dummy:
 #  - "{{ 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 #
 #############
index 9944073ea131b28ccd244fd1f55063e5c51c5d9c..6bdc80ba21d607d2c40f251b3ccf26af9ea5d889 100644 (file)
@@ -62,10 +62,18 @@ crush_rules:
   - "{{ 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 #
 #############
index 29f6b9615aefba19accb4009034b18118a19df4b..4c07375ccc4425a0f988454304fa07ac67a2c433 100644 (file)
@@ -1,52 +1,30 @@
 ---
-- 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() }}"
@@ -56,7 +34,6 @@
 - 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
@@ -66,4 +43,3 @@
     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
-