2017-06-12 16:36:29 +08:00
|
|
|
---
|
2018-02-21 22:20:24 +08:00
|
|
|
- name: configure crush hierarchy
|
|
|
|
ceph_crush:
|
|
|
|
cluster: "{{ cluster }}"
|
|
|
|
location: "{{ hostvars[item]['osd_crush_location'] }}"
|
|
|
|
containerized: "{{ docker_exec_cmd }}"
|
2017-11-16 22:26:27 +08:00
|
|
|
with_items: "{{ groups[osd_group_name] }}"
|
2018-03-02 22:50:01 +08:00
|
|
|
register: config_crush_hierarchy
|
2018-02-21 22:20:24 +08:00
|
|
|
when:
|
2018-03-02 22:50:01 +08:00
|
|
|
- inventory_hostname == groups.get(mon_group_name) | last
|
2018-02-21 22:20:24 +08:00
|
|
|
- create_crush_tree
|
|
|
|
- hostvars[item]['osd_crush_location'] is defined
|
2017-06-12 16:36:29 +08:00
|
|
|
|
|
|
|
- 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
|
2018-03-02 22:50:01 +08:00
|
|
|
when:
|
|
|
|
- inventory_hostname == groups.get(mon_group_name) | last
|
2017-06-12 16:36:29 +08:00
|
|
|
|
|
|
|
- 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
|
|
|
|
with_items: "{{ crush_rules }}"
|
2018-03-02 22:50:01 +08:00
|
|
|
when:
|
|
|
|
- inventory_hostname == groups.get(mon_group_name) | last
|
|
|
|
- item.default
|
2017-06-12 16:36:29 +08:00
|
|
|
|
2018-02-07 02:44:03 +08:00
|
|
|
# If multiple rules are set as default (should not be) then the last one is taken as actual default.
|
2018-03-02 22:50:01 +08:00
|
|
|
# the with_items statement overrides each iteration with the new one.
|
2018-02-21 22:20:24 +08:00
|
|
|
# NOTE(leseb): we should actually fail if multiple rules are set as default
|
2017-09-15 06:48:53 +08:00
|
|
|
- name: set_fact info_ceph_default_crush_rule_yaml
|
2017-06-12 16:36:29 +08:00
|
|
|
set_fact:
|
2018-03-02 22:50:01 +08:00
|
|
|
info_ceph_default_crush_rule_yaml: "{{ item.stdout | from_json() }}"
|
2018-02-07 02:44:03 +08:00
|
|
|
with_items: "{{ info_ceph_default_crush_rule.results }}"
|
2018-03-02 22:50:01 +08:00
|
|
|
when:
|
|
|
|
- inventory_hostname == groups.get(mon_group_name) | last
|
|
|
|
- not item.get('skipped', false)
|
2017-06-12 16:36:29 +08:00
|
|
|
|
2018-10-11 03:24:22 +08:00
|
|
|
- name: set_fact osd_pool_default_crush_rule
|
2018-03-02 21:53:57 +08:00
|
|
|
set_fact:
|
2018-10-11 03:24:22 +08:00
|
|
|
osd_pool_default_crush_rule: "osd_pool_default_crush_rule"
|
2018-03-02 21:53:57 +08:00
|
|
|
|
2017-06-12 16:36:29 +08:00
|
|
|
- name: insert new default crush rule into daemon to prevent restart
|
2018-03-02 22:50:01 +08:00
|
|
|
command: "{{ hostvars[item]['docker_exec_cmd'] | default('') }} ceph --cluster {{ cluster }} daemon mon.{{ hostvars[item]['monitor_name'] }} config set {{ osd_pool_default_crush_rule }} {{ info_ceph_default_crush_rule_yaml.rule_id }}"
|
2017-06-12 16:36:29 +08:00
|
|
|
changed_when: false
|
2018-03-02 22:50:01 +08:00
|
|
|
delegate_to: "{{ item }}"
|
|
|
|
with_items: "{{ groups[mon_group_name] }}"
|
2018-03-02 21:53:57 +08:00
|
|
|
when:
|
2018-03-02 22:50:01 +08:00
|
|
|
- not config_crush_hierarchy.get('skipped', false)
|
|
|
|
- info_ceph_default_crush_rule_yaml | default('') | length > 0
|
2017-06-12 16:36:29 +08:00
|
|
|
|
2018-03-02 21:53:57 +08:00
|
|
|
- name: "add new default crush rule to {{ cluster }}.conf"
|
2017-06-12 16:36:29 +08:00
|
|
|
ini_file:
|
|
|
|
dest: "/etc/ceph/{{ cluster }}.conf"
|
|
|
|
section: "global"
|
2018-03-02 21:53:57 +08:00
|
|
|
option: "{{ osd_pool_default_crush_rule }}"
|
2017-06-12 16:36:29 +08:00
|
|
|
value: "{{ info_ceph_default_crush_rule_yaml.rule_id }}"
|
2018-03-02 22:50:01 +08:00
|
|
|
delegate_to: "{{ item }}"
|
|
|
|
with_items: "{{ groups[mon_group_name] }}"
|
|
|
|
when:
|
|
|
|
- not config_crush_hierarchy.get('skipped', false)
|
|
|
|
- info_ceph_default_crush_rule_yaml | default('') | length > 0
|