Install kubectl via openshift client tools

Instead of installing kubectl with snaps, which seem to be laky
in tests, just download the oc client tools tarball and unpack it.
This is how we get kubectl for the zuul images and it seems to
work nicely there.

Change-Id: I79590a2eeaf32722d231c2bfec35d264696b7e7a
This commit is contained in:
Monty Taylor 2020-02-12 09:40:19 -06:00
parent 8fc86cbd7f
commit fcee508fbc
2 changed files with 29 additions and 11 deletions

View File

@ -0,0 +1,2 @@
kubectl_openshift_url: https://github.com/openshift/origin/releases/download/v3.11.0/openshift-origin-client-tools-v3.11.0-0cbc58b-linux-64bit.tar.gz
kubectl_openshift_checksum: sha256:4b0f07428ba854174c58d2e38287e5402964c9a9355f6c359d1242efd0990da3

View File

@ -1,16 +1,32 @@
- name: Install snapd
package:
name: snapd
state: present
state: absent
- name: Install kubectl
command: snap install kubectl --classic
# /snap/bin is often in the path, but not in a non-login shell, which
# makes it difficult to use via ansible. Add an extra symlink so we
# can always find it.
- name: Symlink snapd into /usr/local/bin
- name: Make /opt/oc directory
file:
src: /snap/bin/kubectl
dest: /usr/local/bin/kubectl
state: link
path: /opt/oc
state: directory
- name: Download openshift client tarball
get_url:
url: "{{ kubectl_openshift_url }}"
checksum: "{{ kubectl_openshift_checksum }}"
dest: /opt/oc.tgz
- name: Extract openshift client tarball
unarchive:
src: /opt/oc.tgz
dest: /opt/oc
extra_opts:
- --strip-components=1
- name: Copy files into /usr/local
copy:
remote_src: true
src: "/opt/oc/{{ item }}"
dest: "/usr/local/bin/{{ item }}"
mode: 0755
loop:
- oc
- kubectl