]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ansible.git/commitdiff
consume ceph_volume module when possible
authorDimitri Savineau <dsavinea@redhat.com>
Wed, 18 Nov 2020 22:20:45 +0000 (17:20 -0500)
committerGuillaume Abrioux <gabrioux@redhat.com>
Tue, 1 Dec 2020 16:54:10 +0000 (17:54 +0100)
We should always use the ceph_volume ansible module when possible.
This patch replace the ceph-volume inventory and lvm {list,zap} commands
called via the command/shell modules by the corresponding call with the
ceph_volume module.

Signed-off-by: Dimitri Savineau <dsavinea@redhat.com>
infrastructure-playbooks/cephadm-adopt.yml
infrastructure-playbooks/filestore-to-bluestore.yml
infrastructure-playbooks/shrink-osd.yml
roles/ceph-osd/tasks/start_osds.yml

index 0f5ed650f65f38b3e3910a094128fa1ad4de3d9b..dd595508d46776564636c46740d244d997b67365 100644 (file)
         tasks_from: container_binary.yml
       when: containerized_deployment | bool
 
-    - name: set_fact ceph_volume
-      set_fact:
-        ceph_volume: "{{ container_binary + ' run --rm --privileged=true --net=host --pid=host --ipc=host -v /dev:/dev -v /etc/ceph:/etc/ceph:z -v /var/lib/ceph:/var/lib/ceph:z -v /var/run:/var/run --entrypoint=ceph-volume ' + ceph_docker_registry + '/' + ceph_docker_image + ':' + ceph_docker_image_tag if containerized_deployment | bool else 'ceph-volume' }}"
-
     - name: get osd list
-      command: "{{ ceph_volume }} --cluster {{ cluster }} lvm list --format json"
-      changed_when: false
+      ceph_volume:
+        cluster: "{{ cluster }}"
+        action: list
+      environment:
+        CEPH_CONTAINER_IMAGE: "{{ ceph_docker_registry + '/' + ceph_docker_image + ':' + ceph_docker_image_tag if containerized_deployment | bool else None }}"
+        CEPH_CONTAINER_BINARY: "{{ container_binary }}"
       register: osd_list
 
     - name: set osd fsid for containerized deployment
index b2f0f90b828b52d54cbce4cc351d0fa79d35b045..ce4e082bab01a2769275c754b96d93c738245dee 100644 (file)
           run_once: true
 
         - name: get ceph-volume lvm inventory data
-          command: "{{ container_run_cmd }} --cluster {{ cluster }} inventory --format json"
+          ceph_volume:
+            cluster: "{{ cluster }}"
+            action: inventory
+          environment:
+            CEPH_CONTAINER_IMAGE: "{{ ceph_docker_registry + '/' + ceph_docker_image + ':' + ceph_docker_image_tag if containerized_deployment | bool else None }}"
+            CEPH_CONTAINER_BINARY: "{{ container_binary }}"
           register: ceph_volume_inventory
 
         - name: set_fact inventory
                 - (item.0.stdout | from_json).encrypted | default(False) | bool
 
             - name: zap data devices
-              command: "{{ container_run_cmd }} --cluster {{ cluster }} lvm zap --destroy {{ (item.0.stdout | from_json).data.path }}"
+              ceph_volume:
+                cluster: "{{ cluster }}"
+                action: zap
+                destroy: true
+                data: "{{ (item.0.stdout | from_json).data.path }}"
+              environment:
+                CEPH_CONTAINER_IMAGE: "{{ ceph_docker_registry + '/' + ceph_docker_image + ':' + ceph_docker_image_tag if containerized_deployment | bool else None }}"
+                CEPH_CONTAINER_BINARY: "{{ container_binary }}"
               with_together:
                 - "{{ simple_scan.results }}"
                 - "{{ partlabel.results }}"
               when: item.1.stdout == 'ceph data'
 
             - name: zap journal devices
-              command: "{{ container_run_cmd }} --cluster {{ cluster }} lvm zap --destroy {{ (item.0.stdout | from_json).journal.path }}"
+              ceph_volume:
+                cluster: "{{ cluster }}"
+                action: zap
+                destroy: true
+                journal: "{{ (item.0.stdout | from_json).journal.path }}"
+              environment:
+                CEPH_CONTAINER_IMAGE: "{{ ceph_docker_registry + '/' + ceph_docker_image + ':' + ceph_docker_image_tag if containerized_deployment | bool else None }}"
+                CEPH_CONTAINER_BINARY: "{{ container_binary }}"
               with_together:
                 - "{{ simple_scan.results }}"
                 - "{{ partlabel.results }}"
                 - (item.0.stdout | from_json).journal.path is defined
 
         - name: get ceph-volume lvm list data
-          command: "{{ container_run_cmd }} --cluster {{ cluster }} lvm list --format json"
+          ceph_volume:
+            cluster: "{{ cluster }}"
+            action: list
+          environment:
+            CEPH_CONTAINER_IMAGE: "{{ ceph_docker_registry + '/' + ceph_docker_image + ':' + ceph_docker_image_tag if containerized_deployment | bool else None }}"
+            CEPH_CONTAINER_BINARY: "{{ container_binary }}"
           register: ceph_volume_lvm_list
 
         - name: set_fact _lvm_list
index 9d75f7e9d86e517787489fbd94f4669bcea89bf9..1e3d874bb388620169c8b0186b62345e5dfa0cd8 100644 (file)
         container_exec_cmd: "{{ container_binary }} exec ceph-mon-{{ ansible_hostname }}"
       when: containerized_deployment | bool
 
-    - 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 | bool else '' }}ceph-volume {{ ceph_docker_registry + '/' + ceph_docker_image + ':' + ceph_docker_image_tag if containerized_deployment | bool else '' }}"
-
     - name: exit playbook, if can not connect to the cluster
       command: "{{ container_exec_cmd }} timeout 5 ceph --cluster {{ cluster }} health"
       register: ceph_health
       when: hostvars[item.0]['ansible_hostname'] == item.1
 
     - name: get ceph-volume lvm list data
-      command: "{{ container_run_cmd }} lvm list --format json"
-      changed_when: false
+      ceph_volume:
+        cluster: "{{ cluster }}"
+        action: list
+      environment:
+        CEPH_CONTAINER_IMAGE: "{{ ceph_docker_registry + '/' + ceph_docker_image + ':' + ceph_docker_image_tag if containerized_deployment | bool else None }}"
+        CEPH_CONTAINER_BINARY: "{{ container_binary }}"
       register: _lvm_list_data
       delegate_to: "{{ item.0 }}"
       loop: "{{ _osd_hosts }}"
         - ceph_osd_data_json[item.2][item.3] is defined
 
     - name: use ceph-volume lvm zap to destroy all partitions
-      command: "{{ container_run_cmd }} lvm zap --destroy {{ ceph_osd_data_json[item.2]['pkname_data'] if item.3 == 'data' else ceph_osd_data_json[item.2][item.3]['path'] }}"
+      ceph_volume:
+        cluster: "{{ cluster }}"
+        action: zap
+        destroy: true
+        data: "{{ ceph_osd_data_json[item.2]['pkname_data'] if item.3 == 'data' else ceph_osd_data_json[item.2][item.3]['path'] }}"
+      environment:
+        CEPH_CONTAINER_IMAGE: "{{ ceph_docker_registry + '/' + ceph_docker_image + ':' + ceph_docker_image_tag if containerized_deployment | bool else None }}"
+        CEPH_CONTAINER_BINARY: "{{ container_binary }}"
       with_nested:
         - "{{ _osd_hosts }}"
         - [ 'block', 'block.db', 'block.wal', 'journal', 'data' ]
index 78ec5be026b819f2ef47877e3323acaaafd6daad..09ed47eb71a82bab8627bb422fd2f624478f7fe3 100644 (file)
@@ -9,14 +9,13 @@
   changed_when: false
   register: osd_ids_non_container
 
-- name: set_fact container_exec_start_osd
-  set_fact:
-    container_exec_start_osd: "{{ container_binary + ' run --rm --net=host --privileged=true -v /var/run/udev/:/var/run/udev/:z -v /run/lvm/:/run/lvm/ -v /etc/ceph:/etc/ceph:z -v /dev:/dev --entrypoint=ceph-volume ' + ceph_docker_registry + '/' + ceph_docker_image + ':' + ceph_docker_image_tag if containerized_deployment | bool else 'ceph-volume' }}"
-
 - name: collect osd ids
-  command: "{{ container_exec_start_osd }} lvm list --format json"
-  changed_when: false
-  failed_when: false
+  ceph_volume:
+    cluster: "{{ cluster }}"
+    action: list
+  environment:
+    CEPH_CONTAINER_IMAGE: "{{ ceph_docker_registry + '/' + ceph_docker_image + ':' + ceph_docker_image_tag if containerized_deployment | bool else None }}"
+    CEPH_CONTAINER_BINARY: "{{ container_binary }}"
   register: ceph_osd_ids
 
 - name: include_tasks systemd.yml