Przeglądaj źródła

Rework Openshift CLI image pulling

Vadim Rutkovsky 7 lat temu
rodzic
commit
378ea22cf0

+ 1 - 0
roles/openshift_cli/defaults/main.yml

@@ -18,3 +18,4 @@ openshift_use_crio_only: False
 openshift_crio_use_rpm: False
 
 l_use_cli_atomic_image: "{{ (openshift_use_crio_only | bool and not openshift_crio_use_rpm | bool) }}"
+l_openshift_cli_image_backend: "{{ (l_use_cli_atomic_image | bool) | ternary('atomic', 'docker') }}"

+ 8 - 20
roles/openshift_cli/tasks/main.yml

@@ -6,36 +6,24 @@
   until: result is succeeded
 
 - block:
-  - name: Pull CLI Image
-    command: >
-      docker pull {{ openshift_cli_image }}
-    register: pull_result
-    changed_when: "'Downloaded newer image' in pull_result.stdout"
-
-  # openshift_container_binary_sync is a custom module in lib_utils
-  - name: Copy client binaries/symlinks out of CLI image for use on the host
-    openshift_container_binary_sync:
-      image: "{{ openshift_cli_image }}"
-      backend: "docker"
-  when:
-  - openshift_is_containerized | bool
-  - not l_use_cli_atomic_image | bool
+  - name: Pull CLI Image (docker)
+    docker_image:
+      name: "{{ openshift_cli_image }}"
+    when: not l_use_cli_atomic_image | bool
 
-- block:
-  - name: Pull CLI Image
+  - name: Pull CLI Image (atomic)
     command: >
       atomic pull --storage ostree {{ system_openshift_cli_image }}
     register: pull_result
     changed_when: "'Pulling layer' in pull_result.stdout"
+    when: l_use_cli_atomic_image | bool
 
   # openshift_container_binary_sync is a custom module in lib_utils
   - name: Copy client binaries/symlinks out of CLI image for use on the host
     openshift_container_binary_sync:
       image: "{{ openshift_cli_image }}"
-      backend: "atomic"
-  when:
-  - openshift_is_containerized | bool
-  - l_use_cli_atomic_image | bool
+      backend: "{{ l_openshift_cli_image_backend }}"
+  when: openshift_is_containerized | bool
 
 - name: Install bash completion for oc tools
   package: name=bash-completion state=present