summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichal Zegan <m.zegan@samsung.com>2019-06-04 16:57:32 +0200
committerMichal Zegan <m.zegan@samsung.com>2019-06-04 17:11:50 +0200
commit551e2682c6c473bdb96aa59ddc18612a436e4b46 (patch)
tree5952841227ae8996120641554437df5e4f6cfaa0
parentdf7d7cc1294c6ea1fcab2ed4ac2ee7c375b29651 (diff)
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 <m.zegan@samsung.com>
-rw-r--r--ansible/test/roles/prepare-kubectl/defaults/main.yml7
-rw-r--r--ansible/test/roles/prepare-kubectl/tasks/main.yml14
2 files changed, 21 insertions, 0 deletions
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 }}"