mirror of https://github.com/ceph/ceph-ansible.git
move crush rule creation from mon to osd role
If we want to create crush rules with the create-replicated sub command
and device class then we need to have the OSD created before the crush
rules otherwise the device classes won't exist.
Signed-off-by: Dimitri Savineau <dsavinea@redhat.com>
(cherry picked from commit ed36a11eab
)
pull/4928/head
parent
f00ee1244f
commit
661b2c013a
|
@ -23,7 +23,3 @@
|
||||||
when:
|
when:
|
||||||
- secure_cluster | bool
|
- secure_cluster | bool
|
||||||
- inventory_hostname == groups[mon_group_name] | first
|
- inventory_hostname == groups[mon_group_name] | first
|
||||||
|
|
||||||
- name: crush_rules.yml
|
|
||||||
include_tasks: crush_rules.yml
|
|
||||||
when: crush_rule_config | bool
|
|
||||||
|
|
|
@ -2,29 +2,29 @@
|
||||||
- name: configure crush hierarchy
|
- name: configure crush hierarchy
|
||||||
ceph_crush:
|
ceph_crush:
|
||||||
cluster: "{{ cluster }}"
|
cluster: "{{ cluster }}"
|
||||||
location: "{{ hostvars[item]['osd_crush_location'] }}"
|
location: "{{ osd_crush_location }}"
|
||||||
containerized: "{{ container_exec_cmd }}"
|
containerized: "{{ hostvars[groups[mon_group_name][0]]['container_exec_cmd'] | default('') }}"
|
||||||
with_items: "{{ groups[osd_group_name] }}"
|
|
||||||
register: config_crush_hierarchy
|
register: config_crush_hierarchy
|
||||||
|
delegate_to: '{{ groups[mon_group_name][0] }}'
|
||||||
when:
|
when:
|
||||||
- inventory_hostname == groups.get(mon_group_name) | last
|
- hostvars[groups[mon_group_name][0]]['create_crush_tree'] | default(false) | bool
|
||||||
- create_crush_tree | bool
|
- osd_crush_location is defined
|
||||||
- hostvars[item]['osd_crush_location'] is defined
|
|
||||||
|
|
||||||
- name: create configured crush rules
|
- name: create configured crush rules
|
||||||
command: "{{ container_exec_cmd }} ceph --cluster {{ cluster }} osd crush rule create-simple {{ item.name }} {{ item.root }} {{ item.type }}"
|
command: "{{ hostvars[groups[mon_group_name][0]]['container_exec_cmd'] | default('') }} ceph --cluster {{ cluster }} osd crush rule create-simple {{ item.name }} {{ item.root }} {{ item.type }}"
|
||||||
with_items: "{{ crush_rules | unique }}"
|
|
||||||
changed_when: false
|
changed_when: false
|
||||||
when: inventory_hostname == groups.get(mon_group_name) | last
|
with_items: "{{ hostvars[groups[mon_group_name][0]]['crush_rules'] | unique }}"
|
||||||
|
delegate_to: '{{ groups[mon_group_name][0] }}'
|
||||||
|
run_once: true
|
||||||
|
|
||||||
- name: get id for new default crush rule
|
- name: get id for new default crush rule
|
||||||
command: "{{ container_exec_cmd }} ceph --cluster {{ cluster }} osd -f json crush rule dump {{ item.name }}"
|
command: "{{ hostvars[groups[mon_group_name][0]]['container_exec_cmd'] | default('') }} ceph --cluster {{ cluster }} osd -f json crush rule dump {{ item.name }}"
|
||||||
register: info_ceph_default_crush_rule
|
register: info_ceph_default_crush_rule
|
||||||
changed_when: false
|
changed_when: false
|
||||||
with_items: "{{ crush_rules }}"
|
with_items: "{{ hostvars[groups[mon_group_name][0]]['crush_rules'] | unique }}"
|
||||||
when:
|
delegate_to: '{{ groups[mon_group_name][0] }}'
|
||||||
- inventory_hostname == groups.get(mon_group_name) | last
|
run_once: true
|
||||||
- item.default
|
when: item.default | bool
|
||||||
|
|
||||||
# If multiple rules are set as default (should not be) then the last one is taken as actual default.
|
# If multiple rules are set as default (should not be) then the last one is taken as actual default.
|
||||||
# the with_items statement overrides each iteration with the new one.
|
# the with_items statement overrides each iteration with the new one.
|
||||||
|
@ -33,15 +33,15 @@
|
||||||
set_fact:
|
set_fact:
|
||||||
info_ceph_default_crush_rule_yaml: "{{ item.stdout | from_json() }}"
|
info_ceph_default_crush_rule_yaml: "{{ item.stdout | from_json() }}"
|
||||||
with_items: "{{ info_ceph_default_crush_rule.results }}"
|
with_items: "{{ info_ceph_default_crush_rule.results }}"
|
||||||
when:
|
run_once: true
|
||||||
- inventory_hostname == groups.get(mon_group_name) | last
|
when: not item.get('skipped', false)
|
||||||
- not item.get('skipped', false)
|
|
||||||
|
|
||||||
- name: insert new default crush rule into daemon to prevent restart
|
- name: insert new default crush rule into daemon to prevent restart
|
||||||
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 }}"
|
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 }}"
|
||||||
changed_when: false
|
changed_when: false
|
||||||
delegate_to: "{{ item }}"
|
delegate_to: "{{ item }}"
|
||||||
with_items: "{{ groups[mon_group_name] }}"
|
with_items: "{{ groups[mon_group_name] }}"
|
||||||
|
run_once: true
|
||||||
when:
|
when:
|
||||||
- not config_crush_hierarchy.get('skipped', false)
|
- not config_crush_hierarchy.get('skipped', false)
|
||||||
- info_ceph_default_crush_rule_yaml | default('') | length > 0
|
- info_ceph_default_crush_rule_yaml | default('') | length > 0
|
||||||
|
@ -54,6 +54,7 @@
|
||||||
value: "{{ info_ceph_default_crush_rule_yaml.rule_id }}"
|
value: "{{ info_ceph_default_crush_rule_yaml.rule_id }}"
|
||||||
delegate_to: "{{ item }}"
|
delegate_to: "{{ item }}"
|
||||||
with_items: "{{ groups[mon_group_name] }}"
|
with_items: "{{ groups[mon_group_name] }}"
|
||||||
|
run_once: true
|
||||||
when:
|
when:
|
||||||
- not config_crush_hierarchy.get('skipped', false)
|
- not config_crush_hierarchy.get('skipped', false)
|
||||||
- info_ceph_default_crush_rule_yaml | default('') | length > 0
|
- info_ceph_default_crush_rule_yaml | default('') | length > 0
|
|
@ -51,6 +51,10 @@
|
||||||
- name: include_tasks start_osds.yml
|
- name: include_tasks start_osds.yml
|
||||||
include_tasks: start_osds.yml
|
include_tasks: start_osds.yml
|
||||||
|
|
||||||
|
- name: include crush_rules.yml
|
||||||
|
include_tasks: crush_rules.yml
|
||||||
|
when: hostvars[groups[mon_group_name][0]]['crush_rule_config'] | default(false) | bool
|
||||||
|
|
||||||
- name: set_fact openstack_keys_tmp - preserve backward compatibility after the introduction of the ceph_keys module
|
- name: set_fact openstack_keys_tmp - preserve backward compatibility after the introduction of the ceph_keys module
|
||||||
set_fact:
|
set_fact:
|
||||||
openstack_keys_tmp: "{{ openstack_keys_tmp|default([]) + [ { 'key': item.key, 'name': item.name, 'caps': { 'mon': item.mon_cap, 'osd': item.osd_cap|default(''), 'mds': item.mds_cap|default(''), 'mgr': item.mgr_cap|default('') } , 'mode': item.mode } ] }}"
|
openstack_keys_tmp: "{{ openstack_keys_tmp|default([]) + [ { 'key': item.key, 'name': item.name, 'caps': { 'mon': item.mon_cap, 'osd': item.osd_cap|default(''), 'mds': item.mds_cap|default(''), 'mgr': item.mgr_cap|default('') } , 'mode': item.mode } ] }}"
|
||||||
|
|
Loading…
Reference in New Issue