Merge "Install kubectl via openshift client tools"

This commit is contained in:
Zuul 2020-04-17 12:49:07 +00:00 committed by Gerrit Code Review
commit f2ca3c8a2e
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