Skip to content

Commit ab51ea2

Browse files
Merge pull request #663 from rsevilla87/unarchive-clients
Unarchive clients in different tasks file
2 parents c4f4d8d + b1d6245 commit ab51ea2

File tree

3 files changed

+45
-26
lines changed

3 files changed

+45
-26
lines changed

ansible/roles/bastion-ocp-version/tasks/main.yml

Lines changed: 19 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -42,35 +42,22 @@
4242
bastion_rhel_version == 'rhel8') |
4343
ternary('openshift-client-linux-amd64-' + bastion_rhel_version, 'openshift-client-linux') }}
4444
45-
- name: Get OpenShift tools when payload_url is not set
46-
get_url:
47-
url: "{{ release_urls[ocp_build] }}/{{ocp_release_version}}/{{ installer_oc_installer_prefix }}-{{ ocp_release_version }}.tar.gz"
48-
dest: "{{ ocp_version_path }}"
49-
mode: 0700
50-
register: client_chk
51-
retries: 3
52-
delay: 5
53-
until: client_chk is not failed
45+
- name: Non-Prow - Get and Unpack OpenShift clients
5446
when: payload_url == ''
47+
block:
5548

56-
- name: Unarchive the clients
57-
unarchive:
58-
src: "{{ ocp_version_path }}/{{ installer_oc_installer_prefix }}-{{ ocp_release_version }}.tar.gz"
59-
dest: "{{ ocp_version_path }}"
60-
remote_src: yes
49+
- name: Get OpenShift tools when payload_url is not set
50+
get_url:
51+
url: "{{ release_urls[ocp_build] }}/{{ocp_release_version}}/{{ installer_oc_installer_prefix }}-{{ ocp_release_version }}.tar.gz"
52+
dest: "{{ ocp_version_path }}"
53+
mode: 0700
54+
register: client_chk
55+
retries: 3
56+
delay: 5
57+
until: client_chk is not failed
6158

62-
- name: Copy correctly versioned oc/kubectl clients into a pathed directory
63-
copy:
64-
src: "{{ item.src }}"
65-
dest: "{{ item.dest }}"
66-
remote_src: true
67-
mode: 0700
68-
loop:
69-
- src: "{{ ocp_version_path }}/oc"
70-
dest: /usr/local/bin/oc
71-
- src: "{{ ocp_version_path }}/kubectl"
72-
dest: /usr/local/bin/kubectl
73-
when: setup_bastion | default(true)
59+
- name: Unarchive clients - payload_url not set
60+
include_tasks: unarchive_clients.yml
7461

7562
- name: Extract/Download the openshift-install binary for the specific release
7663
shell: |
@@ -79,6 +66,12 @@
7966
args:
8067
chdir: "{{ ocp_version_path }}"
8168

69+
# We need to unarchive the clients here to align their versions cluster version
70+
71+
- name: Prow - Unarchive clients - payload_url set
72+
include_tasks: unarchive_clients.yml
73+
when: payload_url != ''
74+
8275
# Prevents errors when attempting to get the display/release name/version and the cluster
8376
# auth-ed by the config is inaccessible
8477
- name: Remove existing /root/.kube/config
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
3+
- name: Unarchive the clients
4+
unarchive:
5+
src: "{{ ocp_version_path }}/{{ installer_oc_installer_prefix }}-{{ ocp_release_version }}.tar.gz"
6+
dest: "{{ ocp_version_path }}"
7+
remote_src: yes
8+
9+
- name: Copy correctly versioned oc/kubectl clients into a pathed directory
10+
copy:
11+
src: "{{ item.src }}"
12+
dest: "{{ item.dest }}"
13+
remote_src: true
14+
mode: 0700
15+
loop:
16+
- src: "{{ ocp_version_path }}/oc"
17+
dest: /usr/local/bin/oc
18+
- src: "{{ ocp_version_path }}/kubectl"
19+
dest: /usr/local/bin/kubectl
20+
when: setup_bastion | default(true)

ansible/roles/ocp-release/tasks/payload_url.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,14 @@
2121
bastion_rhel_version: "rhel8"
2222
when: ansible_facts['distribution_major_version'] is version('8', '==')
2323

24+
- name: Check if oc exists
25+
stat:
26+
path: /usr/local/bin/oc
27+
register: oc_exists
28+
2429
- name: Get latest stable Openshift client
2530
shell: curl -L https://mirror.openshift.com/pub/openshift-v4/clients/ocp/stable/openshift-client-linux-amd64-{{ bastion_rhel_version}}.tar.gz | tar xz -C /usr/local/bin/ oc
31+
when: not oc_exists.stat.exists
2632

2733
- name: Get release info
2834
command: oc adm release info {{ payload_url }}

0 commit comments

Comments
 (0)