<commit_before>---
- name: configure crush hierarchy
  ceph_crush:
    cluster: "{{ cluster }}"
    location: "{{ hostvars[item]['osd_crush_location'] }}"
    containerized: "{{ docker_exec_cmd }}"
  run_once: true
  with_items: "{{ groups[osd_group_name] }}"
  when:
    - create_crush_tree
    - hostvars[item]['osd_crush_location'] is defined

- name: create configured crush rules
  command: "{{ docker_exec_cmd }} ceph --cluster {{ cluster }} osd crush rule create-simple {{ item.name }} {{ item.root }} {{ item.type }}"
  with_items: "{{ crush_rules | unique }}"
  changed_when: false
  run_once: true

- name: get id for new default crush rule
  command: "{{ docker_exec_cmd }} ceph --cluster {{ cluster }} osd -f json crush rule dump {{ item.name }}"
  register: info_ceph_default_crush_rule
  changed_when: false
  with_items: "{{ crush_rules }}"
  when: item.default

# If multiple rules are set as default (should not be) then the last one is taken as actual default.
# NOTE(leseb): we should actually fail if multiple rules are set as default
- name: set_fact info_ceph_default_crush_rule_yaml
  set_fact:
    info_ceph_default_crush_rule_yaml: "{{ item.stdout|from_json() }}"
  with_items: "{{ info_ceph_default_crush_rule.results }}"
  when: not item.get('skipped', false)

- name: insert new default crush rule into daemon to prevent restart
  command: "{{ docker_exec_cmd }} ceph --cluster {{ cluster }} daemon mon.{{ monitor_name }} config set osd_pool_default_crush_replicated_ruleset {{ info_ceph_default_crush_rule_yaml.rule_id }}"
  changed_when: false
  when: info_ceph_default_crush_rule_yaml|default('')|length > 0

- name: add new default crush rule to ceph.conf
  ini_file:
    dest: "/etc/ceph/{{ cluster }}.conf"
    section: "global"
    option: "osd pool default crush replicated ruleset"
    value: "{{ info_ceph_default_crush_rule_yaml.rule_id }}"
  when: info_ceph_default_crush_rule_yaml|default('')|length > 0<commit_msg>mon: fix set crush default rule<commit_after>---
- name: configure crush hierarchy
  ceph_crush:
    cluster: "{{ cluster }}"
    location: "{{ hostvars[item]['osd_crush_location'] }}"
    containerized: "{{ docker_exec_cmd }}"
  run_once: true
  with_items: "{{ groups[osd_group_name] }}"
  when:
    - create_crush_tree
    - hostvars[item]['osd_crush_location'] is defined

- name: create configured crush rules
  command: "{{ docker_exec_cmd }} ceph --cluster {{ cluster }} osd crush rule create-simple {{ item.name }} {{ item.root }} {{ item.type }}"
  with_items: "{{ crush_rules | unique }}"
  changed_when: false
  run_once: true

- name: get id for new default crush rule
  command: "{{ docker_exec_cmd }} ceph --cluster {{ cluster }} osd -f json crush rule dump {{ item.name }}"
  register: info_ceph_default_crush_rule
  changed_when: false
  with_items: "{{ crush_rules }}"
  when: item.default

# If multiple rules are set as default (should not be) then the last one is taken as actual default.
# NOTE(leseb): we should actually fail if multiple rules are set as default
- name: set_fact info_ceph_default_crush_rule_yaml
  set_fact:
    info_ceph_default_crush_rule_yaml: "{{ item.stdout|from_json() }}"
  with_items: "{{ info_ceph_default_crush_rule.results }}"
  when: not item.get('skipped', false)

- name: set_fact osd_pool_default_crush_rule to osd_pool_default_crush_replicated_ruleset if release < luminous else osd_pool_default_crush_rule
  set_fact:
    osd_pool_default_crush_rule: "{{ 'osd_pool_default_crush_replicated_ruleset' if ceph_release_num[ceph_release] < ceph_release_num.luminous else 'osd_pool_default_crush_rule' }}"

- name: insert new default crush rule into daemon to prevent restart
  command: "{{ docker_exec_cmd }} ceph --cluster {{ cluster }} daemon mon.{{ monitor_name }} config set {{ osd_pool_default_crush_rule }} {{ info_ceph_default_crush_rule_yaml.rule_id }}"
  changed_when: false
  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 }}"
  when: info_ceph_default_crush_rule_yaml|default('')|length > 0
{'fraction_non_alphanumeric': 0.11870756263170218, 'fraction_numerical': 0.0009365488176071178, 'mean_word_length': 4.7807848443843035, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '957579', 'n_tokens_mistral': 1457, 'n_tokens_neox': 1438, 'n_words': 360}