diff --git a/playbooks/roles/install-kubectl/defaults/main.yaml b/playbooks/roles/install-kubectl/defaults/main.yaml new file mode 100644 index 0000000000..b0d3f290c8 --- /dev/null +++ b/playbooks/roles/install-kubectl/defaults/main.yaml @@ -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 diff --git a/playbooks/roles/install-kubectl/tasks/main.yaml b/playbooks/roles/install-kubectl/tasks/main.yaml index b308a00fe3..a6aefcf93d 100644 --- a/playbooks/roles/install-kubectl/tasks/main.yaml +++ b/playbooks/roles/install-kubectl/tasks/main.yaml @@ -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