summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.openstack.org>2018-11-05 12:48:55 +0000
committerGerrit Code Review <review@openstack.org>2018-11-05 12:48:55 +0000
commit76fdb33658995b6ddcbad5f66b74bc1d93aae509 (patch)
tree11042ba00e4d21b40b2ab9849c6181e6afafb25f
parent527c528d9ee4849689634603bd55a2df3fa6e905 (diff)
parent230a0f6cc2e483aca5789929ab0bd06b38454099 (diff)
Merge "Add role to install kubernetes"
-rw-r--r--roles/install-kubernetes/README.rst8
-rw-r--r--roles/install-kubernetes/defaults/main.yaml1
-rw-r--r--roles/install-kubernetes/tasks/main.yaml21
-rw-r--r--roles/install-kubernetes/tasks/minikube.yaml48
4 files changed, 78 insertions, 0 deletions
diff --git a/roles/install-kubernetes/README.rst b/roles/install-kubernetes/README.rst
new file mode 100644
index 0000000..ea0d962
--- /dev/null
+++ b/roles/install-kubernetes/README.rst
@@ -0,0 +1,8 @@
1An ansible role to install kubernetes.
2
3**Role Variables**
4
5.. zuul:rolevar:: install_kubernetes_with_cluster
6 :default: True
7
8 If true, installs a Minikube cluster.
diff --git a/roles/install-kubernetes/defaults/main.yaml b/roles/install-kubernetes/defaults/main.yaml
new file mode 100644
index 0000000..19ff90d
--- /dev/null
+++ b/roles/install-kubernetes/defaults/main.yaml
@@ -0,0 +1 @@
install_kubernetes_with_cluster: True
diff --git a/roles/install-kubernetes/tasks/main.yaml b/roles/install-kubernetes/tasks/main.yaml
new file mode 100644
index 0000000..445f71c
--- /dev/null
+++ b/roles/install-kubernetes/tasks/main.yaml
@@ -0,0 +1,21 @@
1- name: Install apt key
2 become: yes
3 apt_key:
4 url: "https://packages.cloud.google.com/apt/doc/apt-key.gpg"
5 state: present
6
7- name: Add kubernetes repo
8 become: yes
9 apt_repository:
10 repo: deb http://apt.kubernetes.io/ kubernetes-xenial main
11 state: present
12
13- name: Install kubernetes packages
14 become: yes
15 apt:
16 name: kubectl
17 update_cache: yes
18
19- name: Run cluster tasks
20 include_tasks: minikube.yaml
21 when: install_kubernetes_with_cluster
diff --git a/roles/install-kubernetes/tasks/minikube.yaml b/roles/install-kubernetes/tasks/minikube.yaml
new file mode 100644
index 0000000..d0c2f50
--- /dev/null
+++ b/roles/install-kubernetes/tasks/minikube.yaml
@@ -0,0 +1,48 @@
1- name: Check for Minikube install
2 stat:
3 path: /tmp/minikube
4 register: stat_result
5
6- name: Download Minikube
7 get_url:
8 url: https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
9 dest: /tmp/minikube
10 mode: 0755
11 when: stat_result.stat.exists == False
12
13- name: Run install-docker role
14 include_role:
15 name: install-docker
16
17- name: Create .kube directory
18 file:
19 path: "{{ ansible_user_dir }}/.kube"
20 state: directory
21 mode: 0755
22
23- name: Create .kube/config file
24 file:
25 path: "{{ ansible_user_dir }}/.kube/config"
26 state: touch
27 mode: 0644
28
29- name: Create .minikube directory
30 file:
31 path: "{{ ansible_user_dir }}/.minikube"
32 state: directory
33 mode: 0755
34
35- name: Start Minikube
36 become: yes
37 command: /tmp/minikube --vm-driver=none start
38 environment:
39 MINIKUBE_WANTUPDATENOTIFICATION: false
40 MINIKUBE_WANTREPORTERRORPROMPT: false
41 MINIKUBE_WANTNONEDRIVERWARNING: false
42 MINIKUBE_WANTKUBECTLDOWNLOADMSG: false
43 CHANGE_MINIKUBE_NONE_USER: true
44 MINIKUBE_HOME: "{{ ansible_user_dir }}"
45 KUBECONFIG: "{{ ansible_user_dir }}/.kube/config"
46
47- name: Get cluster info
48 command: kubectl cluster-info