]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ansible.git/commitdiff
ceph-{mon,osd}: move default crush variables v3.2.40
authorDimitri Savineau <dsavinea@redhat.com>
Mon, 10 Feb 2020 18:43:31 +0000 (13:43 -0500)
committerGuillaume Abrioux <gabrioux@redhat.com>
Mon, 17 Feb 2020 15:23:33 +0000 (16:23 +0100)
Since ed36a11 we move the crush rules creation code from the ceph-mon to
the ceph-osd role.
To keep the backward compatibility we kept the possibility to set the
crush variables on the mons side but we didn't move the default values.
As a result, when using crush_rule_config set to true and wanted to use
the default values for crush_rules then the crush rule ansible task
creation will fail.

"msg": "'ansible.vars.hostvars.HostVarsVars object' has no attribute
'crush_rules'"

This patch move the default crush variables from ceph-mon to ceph-osd
role but also use those default values when nothing is defined on the
mons side.

Closes: https://bugzilla.redhat.com/show_bug.cgi?id=1798864
Signed-off-by: Dimitri Savineau <dsavinea@redhat.com>
(cherry picked from commit 1fc6b337142efdc76c10340c076653d298e11c68)

group_vars/mons.yml.sample
group_vars/osds.yml.sample
infrastructure-playbooks/rolling_update.yml
roles/ceph-mon/defaults/main.yml
roles/ceph-osd/defaults/main.yml
roles/ceph-osd/tasks/crush_rules.yml
roles/ceph-osd/tasks/main.yml

index 44f8bc627a61809c15d0bb3d33fece3e30e6c007..f52ce2064571fb7f7a2a6e26f8f8f81afff09546 100644 (file)
@@ -36,39 +36,6 @@ dummy:
 #  mds: allow *
 #  mgr: allow *
 
-###############
-# CRUSH RULES #
-###############
-#crush_rule_config: false
-
-#crush_rule_hdd:
-#  name: HDD
-#  root: default
-#  type: host
-#  class: hdd
-#  default: false
-
-#crush_rule_ssd:
-#  name: SSD
-#  root: default
-#  type: host
-#  class: ssd
-#  default: false
-
-#crush_rules:
-#  - "{{ crush_rule_hdd }}"
-#  - "{{ crush_rule_ssd }}"
-
-# Caution: this will create crush roots and racks according to hostvars {{ osd_crush_location }}
-# and will move hosts into them which might lead to significant data movement in the cluster!
-#
-# In order for the playbook to create CRUSH hierarchy, you have to setup your Ansible inventory file like so:
-#
-# [osds]
-# ceph-osd-01 osd_crush_location="{ 'root': 'mon-roottt', 'rack': 'mon-rackkkk', 'pod': 'monpod', 'host': 'ceph-osd-01' }"
-#
-# Note that 'host' is mandatory and that you need to submit at least two bucket type (including the host)
-#create_crush_tree: false
 
 ##########
 # DOCKER #
index 4f8cf81404f3b7e6218e2f432bb94c27fa42f4c2..5d615e0cae4131ffddaa76b612ae8915a2a35c8e 100644 (file)
@@ -223,6 +223,39 @@ dummy:
 #crush_device_class: ""
 #osds_per_device: 1
 
+###############
+# CRUSH RULES #
+###############
+#crush_rule_config: false
+
+#crush_rule_hdd:
+#  name: HDD
+#  root: default
+#  type: host
+#  class: hdd
+#  default: false
+
+#crush_rule_ssd:
+#  name: SSD
+#  root: default
+#  type: host
+#  class: ssd
+#  default: false
+
+#crush_rules:
+#  - "{{ crush_rule_hdd }}"
+#  - "{{ crush_rule_ssd }}"
+
+# Caution: this will create crush roots and racks according to hostvars {{ osd_crush_location }}
+# and will move hosts into them which might lead to significant data movement in the cluster!
+#
+# In order for the playbook to create CRUSH hierarchy, you have to setup your Ansible inventory file like so:
+#
+# [osds]
+# ceph-osd-01 osd_crush_location="{ 'root': 'mon-roottt', 'rack': 'mon-rackkkk', 'pod': 'monpod', 'host': 'ceph-osd-01' }"
+#
+# Note that 'host' is mandatory and that you need to submit at least two bucket type (including the host)
+#create_crush_tree: false
 
 ##########
 # DOCKER #
index 12dc327b51aa796d317d729b30f230e79c8c020d..cdd9292adc835a1bd1327e777881879b427aee49 100644 (file)
 - name: run crush rules on osd nodes
   hosts: "{{ osd_group_name|default('osds') }}"
   become: True
-  tasks:
   roles:
     - ceph-defaults
     - ceph-facts
     - import_role:
         name: ceph-osd
         tasks_from: crush_rules
+      when: hostvars[groups[mon_group_name][0]]['crush_rule_config'] | default(false) | bool
 
 
 - name: upgrade ceph mdss cluster, deactivate all rank > 0
index 226cf59a73b4e4c5ea5dd78141c876bf525c0d38..aa6ff08bd57d600942880fb9a933f0913a5d189e 100644 (file)
@@ -28,39 +28,6 @@ client_admin_ceph_authtool_cap:
   mds: allow *
   mgr: allow *
 
-###############
-# CRUSH RULES #
-###############
-crush_rule_config: false
-
-crush_rule_hdd:
-  name: HDD
-  root: default
-  type: host
-  class: hdd
-  default: false
-
-crush_rule_ssd:
-  name: SSD
-  root: default
-  type: host
-  class: ssd
-  default: false
-
-crush_rules:
-  - "{{ crush_rule_hdd }}"
-  - "{{ crush_rule_ssd }}"
-
-# Caution: this will create crush roots and racks according to hostvars {{ osd_crush_location }}
-# and will move hosts into them which might lead to significant data movement in the cluster!
-#
-# In order for the playbook to create CRUSH hierarchy, you have to setup your Ansible inventory file like so:
-#
-# [osds]
-# ceph-osd-01 osd_crush_location="{ 'root': 'mon-roottt', 'rack': 'mon-rackkkk', 'pod': 'monpod', 'host': 'ceph-osd-01' }"
-#
-# Note that 'host' is mandatory and that you need to submit at least two bucket type (including the host)
-create_crush_tree: false
 
 ##########
 # DOCKER #
index 20327a17dceaeed73c4ba0feaa576852fc35d8cf..353f75d340596b8ddc9e84b4bd5fb7cbc31315f5 100644 (file)
@@ -215,6 +215,39 @@ lvm_volumes: []
 crush_device_class: ""
 osds_per_device: 1
 
+###############
+# CRUSH RULES #
+###############
+crush_rule_config: false
+
+crush_rule_hdd:
+  name: HDD
+  root: default
+  type: host
+  class: hdd
+  default: false
+
+crush_rule_ssd:
+  name: SSD
+  root: default
+  type: host
+  class: ssd
+  default: false
+
+crush_rules:
+  - "{{ crush_rule_hdd }}"
+  - "{{ crush_rule_ssd }}"
+
+# Caution: this will create crush roots and racks according to hostvars {{ osd_crush_location }}
+# and will move hosts into them which might lead to significant data movement in the cluster!
+#
+# In order for the playbook to create CRUSH hierarchy, you have to setup your Ansible inventory file like so:
+#
+# [osds]
+# ceph-osd-01 osd_crush_location="{ 'root': 'mon-roottt', 'rack': 'mon-rackkkk', 'pod': 'monpod', 'host': 'ceph-osd-01' }"
+#
+# Note that 'host' is mandatory and that you need to submit at least two bucket type (including the host)
+create_crush_tree: false
 
 ##########
 # DOCKER #
index 412030c31752f706851ec8af1e728ab5d884f672..553d9a9565eb228735c734222a18e3e0bb5f5368 100644 (file)
@@ -7,13 +7,13 @@
   register: config_crush_hierarchy
   delegate_to: '{{ groups[mon_group_name][0] }}'
   when:
-    - hostvars[groups[mon_group_name][0]]['create_crush_tree'] | default(false) | bool
+    - 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]]['docker_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'] | unique }}"
+  with_items: "{{ hostvars[groups[mon_group_name][0]]['crush_rules'] | default(crush_rules) | unique }}"
   delegate_to: '{{ groups[mon_group_name][0] }}'
   run_once: true
 
@@ -21,7 +21,7 @@
   command: "{{ hostvars[groups[mon_group_name][0]]['docker_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'] | unique }}"
+  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 | bool
index 2c03b5370a3d7db5b4c32dc901faa5b283a628db..d202a2d647450f3726392673827d7ad9c0f758fe 100644 (file)
 - name: include crush_rules.yml
   include_tasks: crush_rules.yml
   when:
-    - hostvars[groups[mon_group_name][0]]['crush_rule_config'] | default(false) | bool
+    - hostvars[groups[mon_group_name][0]]['crush_rule_config'] | default(crush_rule_config) | bool
     - not rolling_update | bool
 
 - name: set_fact openstack_keys_tmp - preserve backward compatibility after the introduction of the ceph_keys module