mirror of https://github.com/ceph/ceph-ansible.git
mon: use ceph_crush module in the playbook
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>pull/2436/head
parent
5fac3784f7
commit
73c4846744
|
@ -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 #
|
||||
#############
|
||||
|
|
|
@ -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 #
|
||||
#############
|
||||
|
|
|
@ -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
|
||||
- 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: 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
|
||||
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
|
||||
|
||||
|
|
Loading…
Reference in New Issue