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
|
2019-11-01 04:24:12 +08:00
|
|
|
command: "{{ hostvars[groups[mon_group_name][0]]['container_exec_cmd'] | default('') }} ceph --cluster {{ cluster }} osd crush rule {{ 'create-replicated' if item.class is defined else 'create-simple' }} {{ item.name }} {{ item.root }} {{ item.type }} {{ item.class | default('') }}"
|
2017-06-12 16:36:29 +08:00
|
|
|
changed_when: false
|
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
|
2019-11-01 04:17:33 +08:00
|
|
|
command: "{{ hostvars[groups[mon_group_name][0]]['container_exec_cmd'] | default('') }} ceph --cluster {{ cluster }} osd -f json crush rule dump {{ item.name }}"
|
2017-06-12 16:36:29 +08:00
|
|
|
register: info_ceph_default_crush_rule
|
|
|
|
changed_when: false
|
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
|
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 }}"
|
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
|