-
Notifications
You must be signed in to change notification settings - Fork 25
/
main.yml
83 lines (65 loc) · 2.41 KB
/
main.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# see https://docs.helm.sh/using_helm/#installing-tiller
- name: Install Helm
shell: "snap install helm --classic"
- name: Ensure helm directory exists
file:
path: /root/snap/helm/common/kube/
state: directory
- name: Copy kubeconfig for Tiller
copy:
src: /vagrant/configurationfiles/admin.kubeconfig
dest: /root/snap/helm/common/kube/config
remote_src: yes
- name: Define ServiceAccount name for Tiller
set_fact:
tiller_service_account_name: "tiller"
- name: Template ServiceAccount and ClusterRoleBinding RBAC configfile for Tiller
template:
src: tiller-rbac-config.yaml.j2
dest: /root/snap/helm/common/kube/tiller-rbac-config.yaml
- name: Apply ServiceAccount and ClusterRoleBinding for Tiller
shell: kubectl apply --kubeconfig /vagrant/configurationfiles/admin.kubeconfig -f /root/snap/helm/common/kube/tiller-rbac-config.yaml
- name: Install Tiller
shell: "helm init --service-account {{ tiller_service_account_name }}"
register: helm_init_result
- name: Show helm init result
debug:
msg: "{{ helm_init_result.stdout_lines }}"
- name: Update Helm repos
shell: helm repo update
- name: Verify, if Tiller was installed
shell: kubectl get pods --namespace kube-system -l name=tiller
register: kubectl_kube_system_pods
until: kubectl_kube_system_pods.stdout.find("Running") != -1
retries: 5
delay: 10
# Verify, if Helm was installed successfully
- name: Ensure hello-helm-world directory exists (otherwise, the helm create will fail with permission denied)
file:
path: /home/vagrant/hello-helm-world/
state: directory
- name: Create a Hello-Helm-World Chart
shell: helm create hello-helm-world
become: yes
- name: Override values.yaml for setting node-hello instead of nginx as image
copy:
src: values.yaml
dest: /home/vagrant/hello-helm-world/values.yaml
force: yes
- name: Run Hello-Helm-World Chart
shell: "helm install --name hello-helm-world ./hello-helm-world"
- name: Check if Hello-Helm-World Pod is running
shell: kubectl get pods -l app=hello-helm-world
register: helm_result
until: helm_result.stdout.find("Running") != -1
retries: 10
delay: 10
- name: Show Hello-Helm-World Pod
debug:
msg: "{{ helm_result.stdout_lines }}"
- name: Delete Hello-Helm-World Release
shell: "helm delete --purge hello-helm-world"
- name: Delete hello-helm-world directory
file:
path: /home/vagrant/hello-helm-world/
state: absent