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'] }}"
|
2019-05-14 20:51:32 +08:00
|
|
|
containerized: "{{ container_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
|
2019-05-22 16:02:42 +08:00
|
|
|
- create_crush_tree | bool
|
2018-02-21 22:20:24 +08:00
|
|
|
- hostvars[item]['osd_crush_location'] is defined
|
2017-06-12 16:36:29 +08:00
|
|
|
|
|
|
|
- name: create configured crush rules
|
2019-05-14 20:51:32 +08:00
|
|
|
command: "{{ container_exec_cmd }} ceph --cluster {{ cluster }} osd crush rule create-simple {{ item.name }} {{ item.root }} {{ item.type }}"
|
2017-06-12 16:36:29 +08:00
|
|
|
with_items: "{{ crush_rules | unique }}"
|
|
|
|
changed_when: false
|
2019-04-01 23:46:15 +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
|
2019-05-14 20:51:32 +08:00
|
|
|
command: "{{ container_exec_cmd }} 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
|
|
|
|
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
|
|
|
|
|
|
|
- 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] }}"
|
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"
|
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] }}"
|
|
|
|
when:
|
|
|
|
- not config_crush_hierarchy.get('skipped', false)
|
|
|
|
- info_ceph_default_crush_rule_yaml | default('') | length > 0
|