From 551e2682c6c473bdb96aa59ddc18612a436e4b46 Mon Sep 17 00:00:00 2001 From: Michal Zegan Date: Tue, 4 Jun 2019 16:57:32 +0200 Subject: Add prepare-kubectl role This role is used to prepare for kubectl role tests. It may also be used when any other test needs installed kubectl, for example when verifying kubernetes cluster setup. Both cases are a bit different. Change-Id: Ie7a065c571d94f40cfd64c3eba78af3e84b3f08a Issue-ID: OOM-1908 Signed-off-by: Michal Zegan --- ansible/test/roles/prepare-kubectl/defaults/main.yml | 7 +++++++ ansible/test/roles/prepare-kubectl/tasks/main.yml | 14 ++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 ansible/test/roles/prepare-kubectl/defaults/main.yml create mode 100644 ansible/test/roles/prepare-kubectl/tasks/main.yml (limited to 'ansible/test/roles') diff --git a/ansible/test/roles/prepare-kubectl/defaults/main.yml b/ansible/test/roles/prepare-kubectl/defaults/main.yml new file mode 100644 index 00000000..d4e8ef94 --- /dev/null +++ b/ansible/test/roles/prepare-kubectl/defaults/main.yml @@ -0,0 +1,7 @@ +--- +# Set to false to download kubectl in preparation for kubectl role that +# needs to install it, set to true to immediately install (needed for +# cases where it is used by verification tests of other roles). +kubectl_install: false +# Kubectl version. +kubectl_version: 1.13.5 diff --git a/ansible/test/roles/prepare-kubectl/tasks/main.yml b/ansible/test/roles/prepare-kubectl/tasks/main.yml new file mode 100644 index 00000000..b5631850 --- /dev/null +++ b/ansible/test/roles/prepare-kubectl/tasks/main.yml @@ -0,0 +1,14 @@ +--- +- name: "Ensure {{ app_data_path }} exists" + file: + path: "{{ app_data_path }}/downloads" + state: directory + when: not kubectl_install + +- name: "Install kubectl-{{ kubectl_version }}" + get_url: + url: "https://storage.googleapis.com/kubernetes-release/release/v{{ kubectl_version }}/bin/linux/amd64/kubectl" + dest: "{{ '/usr/local/bin/kubectl' if kubectl_install else app_data_path+'/downloads/kubectl' }}" + # This mode conditional allows checking if kubectl role, when installing kubectl, correctly + # adds executable bit (bonus). + mode: "{{ 0755 if kubectl_install else omit }}" -- cgit 1.2.3-korg