]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ansible.git/commitdiff
fs2bs: support `osd_auto_discovery` scenario
authorGuillaume Abrioux <gabrioux@redhat.com>
Wed, 23 Sep 2020 14:21:21 +0000 (16:21 +0200)
committerGuillaume Abrioux <gabrioux@redhat.com>
Tue, 29 Sep 2020 14:28:43 +0000 (16:28 +0200)
This commit adds the `osd_auto_discovery` scenario support in the
filestore-to-bluestore playbook.

Closes: https://bugzilla.redhat.com/show_bug.cgi?id=1881523
Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
Co-authored-by: Dimitri Savineau <dsavinea@redhat.com>
(cherry picked from commit 8b1eeef18a4ae953cf568e750c5cf1e3e96e0b78)

infrastructure-playbooks/filestore-to-bluestore.yml

index 1ed6208df9bcdc49dc0f90628ef6b6d455989b6e..d12c6f10bc45b0c432edb30d816dd567223c870c 100644 (file)
       block:
         - import_role:
             name: ceph-facts
+            tasks_from: container_binary.yml
+
+        - name: set_fact container_run_cmd, container_exec_cmd
+          set_fact:
+            container_run_cmd: "{{ container_binary + ' run --rm --privileged=true --net=host --pid=host --ipc=host -v /dev:/dev -v /etc/ceph:/etc/ceph -v /var/lib/ceph:/var/lib/ceph -v /var/run:/var/run --entrypoint=' if containerized_deployment | bool else '' }}ceph-volume {{ ceph_docker_registry + '/' + ceph_docker_image + ':' + ceph_docker_image_tag if containerized_deployment | bool else '' }}"
+            container_exec_cmd: "{{ container_binary + ' exec ceph-mon-' + hostvars[groups[mon_group_name][0]]['ansible_hostname'] if containerized_deployment | bool else '' }}"
+
 
         - name: get ceph osd tree data
           command: "{{ container_exec_cmd }} ceph osd tree -f json"
           register: osd_tree
           run_once: true
 
-        - name: set_fact container_run_cmd
-          set_fact:
-            container_run_cmd: "{{ container_binary + ' run --rm --privileged=true --net=host --pid=host --ipc=host -v /dev:/dev -v /etc/ceph:/etc/ceph -v /var/lib/ceph:/var/lib/ceph -v /var/run:/var/run --entrypoint=' if containerized_deployment else '' }}ceph-volume {{ ceph_docker_registry + '/' + ceph_docker_image + ':' + ceph_docker_image_tag if containerized_deployment else '' }}"
-
         - name: get ceph-volume lvm inventory data
           command: "{{ container_run_cmd }} --cluster {{ cluster }} inventory --format json"
           register: ceph_volume_inventory
 
             - name: set_fact osd_fsid_list
               set_fact:
-                osd_fsid_list: "{{ osd_fsid_list | default([]) + [{'osd_fsid': item.tags['ceph.osd_fsid'], 'destroy': (item.lv_name.startswith('osd-data-') and item.vg_name.startswith('ceph-')) | ternary(true, false), 'device': item.devices[0]}] }}"
+                osd_fsid_list: "{{ osd_fsid_list | default([]) + [{'osd_fsid': item.tags['ceph.osd_fsid'], 'destroy': (item.lv_name.startswith('osd-data-') and item.vg_name.startswith('ceph-')) | ternary(true, false), 'device': item.devices[0], 'journal': item['tags']['ceph.journal_device'] }] }}"
               with_items: "{{ _lvm_list }}"
               when: item.type == 'data'
 
                 - osd_fsid_list is defined
                 - item.destroy | bool
 
+            - name: test if the journal device hasn't been already destroyed because of collocation
+              stat:
+                path: "{{ item.journal }}"
+              loop: "{{ osd_fsid_list }}"
+              register: journal_path
+              when:
+                - osd_fsid_list is defined
+                - item.destroy | bool
+                - item.journal is defined
+                - item.journal not in (lvm_volumes | selectattr('journal', 'defined') | map(attribute='journal') | list)
+
+            - name: zap destroy ceph-volume prepared journal devices
+              ceph_volume:
+                action: "zap"
+                data: "{{ item.0.journal }}"
+                destroy: true
+              environment:
+                CEPH_VOLUME_DEBUG: "{{ ceph_volume_debug }}"
+                CEPH_CONTAINER_IMAGE: "{{ ceph_docker_registry + '/' + ceph_docker_image + ':' + ceph_docker_image_tag if containerized_deployment else None }}"
+                CEPH_CONTAINER_BINARY: "{{ container_binary }}"
+              loop: "{{ osd_fsid_list | zip(journal_path.results) | list }}"
+              when:
+                - osd_fsid_list is defined
+                - item.0.destroy | bool
+                - item.0.journal is defined
+                - item.0.journal not in (lvm_volumes | selectattr('journal', 'defined') | map(attribute='journal') | list)
+                - item.1.stat.exists | bool
+
             - name: ensure all dm are closed
               command: dmsetup remove "{{ item['lv_path'] }}"
               with_items: "{{ _lvm_list }}"
           with_items:
             - "{{ ((osd_tree.stdout | default('{}') | from_json).nodes | selectattr('name', 'match', inventory_hostname) | map(attribute='children') | list) }}"
 
-
         - name: purge osd(s) from the cluster
           command: >
             {{ container_exec_cmd }} ceph --cluster {{ cluster }} osd purge {{ item }} --yes-i-really-mean-it
             state: absent
           with_items: "{{ osd_ids }}"
 
-        - name: remove gpt header
-          command: parted -s "{{ item }}" mklabel msdos
-          with_items: "{{ (devices + dedicated_devices + ceph_disk_osds_devices | default([])) | unique }}"
+        - name: force osd_objectstore to bluestore
+          set_fact:
+            osd_objectstore: bluestore
 
         - name: refresh ansible devices fact
           setup:
             filter: ansible_devices
           when: osd_auto_discovery | bool
 
+        - import_role:
+            name: ceph-defaults
+        - import_role:
+            name: ceph-facts
+
+        - name: remove gpt header
+          command: parted -s "{{ item }}" mklabel msdos
+          with_items: "{{ (devices + dedicated_devices | default([]) + ceph_disk_osds_devices | default([])) | unique }}"
+
         - name: update lvm_volumes configuration for bluestore
-          when: lvm_volumes is defined
+          when:
+            - lvm_volumes | length > 0
+            - not osd_auto_discovery | bool
           block:
             - name: reuse filestore journal partition for bluestore db
               set_fact:
               set_fact:
                 lvm_volumes: "{{ config_part | default([]) + config_vglv | default([]) }}"
 
-        - name: force osd_objectstore to bluestore
-          set_fact:
-            osd_objectstore: bluestore
-
-        - import_role:
-            name: ceph-defaults
-        - import_role:
-            name: ceph-facts
         - import_role:
             name: ceph-handler
         - import_role: