Skip to content

Commit

Permalink
Move ocp tools extraction out of main.yaml (ocp-power-automation#33)
Browse files Browse the repository at this point in the history
Fixes: ocp-power-automation#32
Signed-off-by: Prajyot Parab <[email protected]>
  • Loading branch information
Prajyot-Parab authored Jul 29, 2020
1 parent ba81cfa commit de6b123
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 48 deletions.
55 changes: 55 additions & 0 deletions playbooks/roles/ocp-config/tasks/extract.yaml
Original file line number Diff line number Diff line change
@@ -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

50 changes: 2 additions & 48 deletions playbooks/roles/ocp-config/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit de6b123

Please sign in to comment.