2017-06-12 16:36:29 +08:00
|
|
|
---
|
2018-02-21 22:20:24 +08:00
|
|
|
- name: configure crush hierarchy
|
|
|
|
ceph_crush:
|
|
|
|
cluster: "{{ cluster }}"
|
2019-11-01 04:17:33 +08:00
|
|
|
location: "{{ osd_crush_location }}"
|
|
|
|
containerized: "{{ hostvars[groups[mon_group_name][0]]['container_exec_cmd'] | default('') }}"
|
2018-03-02 22:50:01 +08:00
|
|
|
register: config_crush_hierarchy
|
2019-11-01 04:17:33 +08:00
|
|
|
delegate_to: '{{ groups[mon_group_name][0] }}'
|
2018-02-21 22:20:24 +08:00
|
|
|
when:
|
2020-02-11 02:43:31 +08:00
|
|
|
- hostvars[groups[mon_group_name][0]]['create_crush_tree'] | default(create_crush_tree) | bool
|
2019-11-01 04:17:33 +08:00
|
|
|
- osd_crush_location is defined
|
2017-06-12 16:36:29 +08:00
|
|
|
|
|
|
|
- name: create configured crush rules
|
2020-11-10 01:16:41 +08:00
|
|
|
ceph_crush_rule:
|
|
|
|
name: "{{ item.name }}"
|
|
|
|
cluster: "{{ cluster }}"
|
|
|
|
rule_type: replicated
|
|
|
|
bucket_root: "{{ item.root }}"
|
|
|
|
bucket_type: "{{ item.type }}"
|
|
|
|
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 }}"
|
2020-02-11 02:43:31 +08:00
|
|
|
with_items: "{{ hostvars[groups[mon_group_name][0]]['crush_rules'] | default(crush_rules) | unique }}"
|
2019-11-01 04:17:33 +08:00
|
|
|
delegate_to: '{{ groups[mon_group_name][0] }}'
|
|
|
|
run_once: true
|
2017-06-12 16:36:29 +08:00
|
|
|
|
|
|
|
- name: get id for new default crush rule
|
2020-11-10 01:16:41 +08:00
|
|
|
ceph_crush_rule:
|
|
|
|
name: "{{ item.name }}"
|
|
|
|
cluster: "{{ cluster }}"
|
|
|
|
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 }}"
|
2017-06-12 16:36:29 +08:00
|
|
|
register: info_ceph_default_crush_rule
|
2020-02-11 02:43:31 +08:00
|
|
|
with_items: "{{ hostvars[groups[mon_group_name][0]]['crush_rules'] | default(crush_rules) | unique }}"
|
2019-11-01 04:17:33 +08:00
|
|
|
delegate_to: '{{ groups[mon_group_name][0] }}'
|
|
|
|
run_once: true
|
2020-03-24 16:56:45 +08:00
|
|
|
when: item.default | default(False) | bool
|
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
|
2020-03-27 23:21:09 +08:00
|
|
|
- name: set_fact info_ceph_default_crush_rule_yaml, ceph_osd_pool_default_crush_rule_name
|
2017-06-12 16:36:29 +08:00
|
|
|
set_fact:
|
2021-12-13 21:41:23 +08:00
|
|
|
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') }}"
|
2018-02-07 02:44:03 +08:00
|
|
|
with_items: "{{ info_ceph_default_crush_rule.results }}"
|
2019-11-01 04:17:33 +08:00
|
|
|
run_once: true
|
|
|
|
when: not item.get('skipped', false)
|
2017-06-12 16:36:29 +08:00
|
|
|
|
|
|
|
- name: insert new default crush rule into daemon to prevent restart
|
2019-10-28 23:30:39 +08:00
|
|
|
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 }}"
|
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] }}"
|
2019-11-01 04:17:33 +08:00
|
|
|
run_once: true
|
2018-03-02 21:53:57 +08:00
|
|
|
when:
|
2018-03-02 22:50:01 +08:00
|
|
|
- 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"
|
2019-03-08 06:14:12 +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] }}"
|
2019-11-01 04:17:33 +08:00
|
|
|
run_once: true
|
2018-03-02 22:50:01 +08:00
|
|
|
when:
|
|
|
|
- info_ceph_default_crush_rule_yaml | default('') | length > 0
|