--- - name: configure crush hierarchy ceph_crush: cluster: "{{ cluster }}" location: "{{ osd_crush_location }}" containerized: "{{ hostvars[groups[mon_group_name][0]]['container_exec_cmd'] | default('') }}" register: config_crush_hierarchy delegate_to: '{{ groups[mon_group_name][0] }}' when: - hostvars[groups[mon_group_name][0]]['create_crush_tree'] | default(create_crush_tree) | bool - osd_crush_location is defined - name: create configured crush rules 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('') }}" changed_when: false with_items: "{{ hostvars[groups[mon_group_name][0]]['crush_rules'] | default(crush_rules) | unique }}" delegate_to: '{{ groups[mon_group_name][0] }}' run_once: true - name: get id for new default crush rule 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 changed_when: false with_items: "{{ hostvars[groups[mon_group_name][0]]['crush_rules'] | default(crush_rules) | unique }}" delegate_to: '{{ groups[mon_group_name][0] }}' run_once: true when: item.default | default(False) | bool # 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. # NOTE(leseb): we should actually fail if multiple rules are set as default - name: set_fact info_ceph_default_crush_rule_yaml, ceph_osd_pool_default_crush_rule_name set_fact: info_ceph_default_crush_rule_yaml: "{{ item.stdout | from_json() }}" ceph_osd_pool_default_crush_rule_name: "{{ (item.stdout | from_json).rule_name }}" with_items: "{{ info_ceph_default_crush_rule.results }}" run_once: true when: not item.get('skipped', false) - 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 }}" changed_when: false delegate_to: "{{ item }}" with_items: "{{ groups[mon_group_name] }}" run_once: true when: - info_ceph_default_crush_rule_yaml | default('') | length > 0 - name: "add new default crush rule to {{ cluster }}.conf" ini_file: dest: "/etc/ceph/{{ cluster }}.conf" section: "global" option: "osd pool default crush rule" value: "{{ info_ceph_default_crush_rule_yaml.rule_id }}" delegate_to: "{{ item }}" with_items: "{{ groups[mon_group_name] }}" run_once: true when: - info_ceph_default_crush_rule_yaml | default('') | length > 0