|
1 | 1 | --- |
| 2 | +# Extract OCP installer and/or client binaries directly from the release image |
| 3 | +# using `oc adm release extract --tools` instead of the release-controller's |
| 4 | +# file-cache (openshift-release-artifacts), which has no SLA and can get stuck |
| 5 | +# indefinitely during tool extraction. |
2 | 6 | - name: Get the OCP installer and/or client binaries |
3 | 7 | vars: |
4 | | - installer_url: "{{ openshift_download_url }}/openshift-install-linux-{{ release_name }}.tar.gz" |
5 | | - client_url: "{{ openshift_download_url }}/openshift-client-linux-{{ release_name }}.tar.gz" |
| 8 | + installer_tarball: "openshift-install-linux-{{ release_name }}.tar.gz" |
| 9 | + client_tarball: "openshift-client-linux-{{ release_name }}.tar.gz" |
| 10 | + pull_secret_file: "{{ home_dir }}/pull-secret.json" |
6 | 11 | block: |
7 | 12 | - name: Fail if release_name var is not defined |
8 | 13 | ansible.builtin.fail: |
9 | 14 | msg: "'release_name' variable must be defined and cannot be empty" |
10 | 15 | when: release_name == '' |
11 | 16 |
|
12 | | - - name: Wait for content to come up on {{ openshift_download_url }} |
13 | | - ansible.builtin.uri: |
14 | | - url: "{{ openshift_download_url }}" |
15 | | - method: GET |
16 | | - return_content: yes |
17 | | - status_code: 200 |
18 | | - body_format: json |
19 | | - register: result |
20 | | - until: result.content.find("openshift-install-linux") != -1 |
21 | | - retries: 20 |
22 | | - delay: 60 |
| 17 | + - name: Fail if openshift_release_pull_spec is not defined |
| 18 | + ansible.builtin.fail: |
| 19 | + msg: "'openshift_release_pull_spec' must be set by get_openshift_release_build_name.yml" |
| 20 | + when: openshift_release_pull_spec is not defined or openshift_release_pull_spec == '' |
| 21 | + |
| 22 | + - name: Extract pull secret from host cluster |
| 23 | + ansible.builtin.shell: >- |
| 24 | + set -o pipefail && |
| 25 | + oc get secret pull-secret -n openshift-config |
| 26 | + --kubeconfig={{ rhoso_kubeconfig }} |
| 27 | + -o jsonpath='{.data.\.dockerconfigjson}' |
| 28 | + | base64 -d > {{ pull_secret_file }} |
| 29 | + changed_when: true |
| 30 | + no_log: true |
23 | 31 |
|
24 | 32 | - name: Create the installer directory |
25 | 33 | ansible.builtin.file: |
26 | 34 | path: "{{ home_dir }}/{{ release_name }}" |
27 | 35 | state: directory |
28 | 36 | mode: u=rwx,g=rw,o=r |
29 | 37 |
|
| 38 | + - name: Extract OCP tools from release image {{ openshift_release_pull_spec }} |
| 39 | + ansible.builtin.command: |
| 40 | + cmd: >- |
| 41 | + oc adm release extract |
| 42 | + --tools |
| 43 | + --registry-config={{ pull_secret_file }} |
| 44 | + --to={{ home_dir }}/{{ release_name }} |
| 45 | + {{ openshift_release_pull_spec }} |
| 46 | + register: extract_result |
| 47 | + until: extract_result is not failed |
| 48 | + retries: 3 |
| 49 | + delay: 30 |
| 50 | + |
30 | 51 | - name: Get the installer binary and create a symlink |
31 | 52 | when: "'installer' in binaries" |
32 | 53 | block: |
33 | | - - name: Download and unarchive the installer from {{ installer_url }} |
| 54 | + - name: Unarchive the installer from {{ installer_tarball }} |
34 | 55 | ansible.builtin.unarchive: |
35 | | - src: "{{ installer_url }}" |
| 56 | + src: "{{ home_dir }}/{{ release_name }}/{{ installer_tarball }}" |
36 | 57 | dest: "{{ home_dir }}/{{ release_name }}" |
37 | 58 | remote_src: yes |
38 | | - register: result |
39 | | - until: result is not failed |
40 | | - retries: 3 |
41 | | - delay: 10 |
42 | 59 |
|
43 | 60 | - name: Create a symlink to the openshift-install binary from /usr/local/bin |
44 | 61 | ansible.builtin.file: |
|
47 | 64 | state: link |
48 | 65 | become: true |
49 | 66 |
|
50 | | - - name: Get the installer binary and create symlinks |
| 67 | + - name: Get the client binary and create symlinks |
51 | 68 | when: "'client' in binaries" |
52 | 69 | block: |
53 | | - - name: Download and unarchive the client from {{ client_url }} |
| 70 | + - name: Unarchive the client from {{ client_tarball }} |
54 | 71 | ansible.builtin.unarchive: |
55 | | - src: "{{ client_url }}" |
| 72 | + src: "{{ home_dir }}/{{ release_name }}/{{ client_tarball }}" |
56 | 73 | dest: "{{ home_dir }}/{{ release_name }}" |
57 | 74 | remote_src: yes |
58 | | - register: result |
59 | | - until: result is not failed |
60 | | - retries: 3 |
61 | | - delay: 10 |
62 | 75 |
|
63 | 76 | - name: Create a symlink to the oc binary from /usr/local/bin |
64 | 77 | ansible.builtin.file: |
|
73 | 86 | dest: /usr/bin/kubectl |
74 | 87 | state: link |
75 | 88 | become: true |
| 89 | + |
| 90 | + always: |
| 91 | + - name: Remove pull secret file |
| 92 | + ansible.builtin.file: |
| 93 | + path: "{{ pull_secret_file }}" |
| 94 | + state: absent |
0 commit comments