]> git.apps.os.sepia.ceph.com Git - ceph-ansible.git/commitdiff
site: choose the right container runtime binary
authorSébastien Han <seb@redhat.com>
Mon, 19 Nov 2018 14:14:55 +0000 (15:14 +0100)
committermergify[bot] <mergify[bot]@users.noreply.github.com>
Tue, 27 Nov 2018 16:47:40 +0000 (16:47 +0000)
We need to verify wether podman exists or not, if yes we use it instead
of docker.

Signed-off-by: Sébastien Han <seb@redhat.com>
site-container.yml.sample

index d25359775b537829b8af73e16bf41d7a55933088..0f4cf9d08c66d4ac6eecc989702af730d93c3d6c 100644 (file)
       tags:
         - always
 
+    - name: check if podman binary is present
+      stat:
+        path: /usr/bin/podman
+      register: podman_binary
+
+    - name: set_fact container_binary
+      set_fact:
+        container_binary: "{{ 'podman' if podman_binary.stat.exists else 'docker' }}"
+
     - import_role:
         name: ceph-defaults
         private: false
         - not (is_atomic | bool)
         - (not (inventory_hostname in groups.get('clients', [])) or (inventory_hostname == groups.get('clients', [''])|first))
 
-
     # post-tasks for upcoming import -
     - name: "pull {{ ceph_docker_image }} image"
-      command: "docker pull {{ ceph_docker_registry }}/{{ ceph_docker_image }}:{{ ceph_docker_image_tag }}"
+      command: "{{ container_binary }} pull {{ ceph_docker_registry}}/{{ ceph_docker_image }}:{{ ceph_docker_image_tag }}"
       changed_when: false
       when:
         - is_atomic
   gather_facts: false
   become: True
   tasks:
+    - name: check if podman binary is present
+      stat:
+        path: /usr/bin/podman
+      register: podman_binary
+
     - name: get ceph status from the first monitor
-      command: docker exec ceph-mon-{{ hostvars[groups['mons'][0]]['ansible_hostname'] }} ceph --cluster {{ cluster | default ('ceph') }} -s
+      command: >
+        {{ 'podman' if podman_binary.stat.exists else 'docker' }} exec ceph-mon-{{ hostvars[groups['mons'][0]]['ansible_hostname'] }} ceph --cluster {{ cluster | default ('ceph') }} -s
       register: ceph_status
       changed_when: false
       delegate_to: "{{ groups['mons'][0] }}"