From de6b1232281403088eb6fb22bc53e3a847a9ad44 Mon Sep 17 00:00:00 2001 From: Prajyot Parab <42934355+Prajyot-Parab@users.noreply.github.com> Date: Wed, 29 Jul 2020 11:39:57 +0530 Subject: [PATCH] Move ocp tools extraction out of main.yaml (#33) Fixes: #32 Signed-off-by: Prajyot Parab --- playbooks/roles/ocp-config/tasks/extract.yaml | 55 +++++++++++++++++++ playbooks/roles/ocp-config/tasks/main.yaml | 50 +---------------- 2 files changed, 57 insertions(+), 48 deletions(-) create mode 100644 playbooks/roles/ocp-config/tasks/extract.yaml diff --git a/playbooks/roles/ocp-config/tasks/extract.yaml b/playbooks/roles/ocp-config/tasks/extract.yaml new file mode 100644 index 00000000..a72246ff --- /dev/null +++ b/playbooks/roles/ocp-config/tasks/extract.yaml @@ -0,0 +1,55 @@ +--- + +- name: Set tools directory path + set_fact: + tools_dir: "~/ocp4_tools" + +- name: Create tools directory + file: + path: "{{ tools_dir }}" + state: "{{ item }}" + mode: '0755' + with_items: + - directory + +- name: Extract OCP4 tools from release image ( local-registry ) + when: enable_local_registry + shell: | + oc adm release extract --tools {{ release_image_override }} --registry-config='{{ ansible_env.HOME }}/.openshift/pull-secret-updated' + args: + chdir: "{{ tools_dir }}" + +- name: Create pull-secret file + when: not enable_local_registry + copy: + content: "{{ install_config.pull_secret }}" + dest: "{{ tools_dir }}/pull-secret" + +- name: Extract OCP4 tools from release image + when: not enable_local_registry + shell: | + oc adm release extract --tools {{ release_image_override }} --registry-config='pull-secret' + args: + chdir: "{{ tools_dir }}" + +- name: Find archive packages + find: + paths: "{{ tools_dir }}" + patterns: "openshift-*.tar.gz" + register: find_result + +- name: Unarchive OCP4 tool files + unarchive: + src: "{{ item.path }}" + dest: /usr/local/bin + remote_src: yes + with_items: "{{ find_result.files }}" + +- name: Remove tools directory + file: + path: "{{ tools_dir }}" + state: "{{ item }}" + mode: '0755' + with_items: + - absent + diff --git a/playbooks/roles/ocp-config/tasks/main.yaml b/playbooks/roles/ocp-config/tasks/main.yaml index 695aba71..4bd1255f 100644 --- a/playbooks/roles/ocp-config/tasks/main.yaml +++ b/playbooks/roles/ocp-config/tasks/main.yaml @@ -7,55 +7,9 @@ - name: Extract OCP4 tools + import_tasks: extract.yaml when: release_image_override != "" - block: - - name: Set tools directory path - set_fact: - tools_dir: "~/ocp4_tools" - - - name: Create tools directory - file: - path: "{{ tools_dir }}" - state: "{{ item }}" - mode: '0755' - with_items: - - directory - - - name: Extract OCP4 tools from release image ( local-registry ) - when: enable_local_registry - shell: | - oc adm release extract --tools {{ release_image_override }} --registry-config='{{ ansible_env.HOME }}/.openshift/pull-secret-updated' - args: - chdir: "{{ tools_dir }}" - - - name: Extract OCP4 tools from release image - when: not enable_local_registry - shell: | - echo '{{ install_config.pull_secret }}' > pull_secret - oc adm release extract --tools {{ release_image_override }} --registry-config='pull_secret' - args: - chdir: "{{ tools_dir }}" - - - name: Find archive packages - find: - paths: "{{ tools_dir }}" - patterns: "openshift-*.tar.gz" - register: find_result - - - name: Unarchive OCP4 tool files - unarchive: - src: "{{ item.path }}" - dest: /usr/local/bin - remote_src: yes - with_items: "{{ find_result.files }}" - - - name: Remove tools directory - file: - path: "{{ tools_dir }}" - state: "{{ item }}" - mode: '0755' - with_items: - - absent + - name: Skip config if install workdir exist stat: