forked from kubealex/libvirt-k8s-provisioner
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path31_install_rancher.yml
78 lines (63 loc) · 2.82 KB
/
31_install_rancher.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
---
- name: Prepare cluster to install rancher
hosts: masters
run_once: true
vars_files:
- vars/k8s_cluster.yml
tasks:
- block:
- name: Ensure helm is installed
unarchive:
src: "{{ helm.helm_installer }}"
dest: /tmp/
remote_src: true
- name: Install helm in PATH
copy:
src: /tmp/linux-amd64/helm
dest: /usr/local/bin/
remote_src: true
mode: +x
become: true
- name: remove directory
file:
path: /tmp/linux-amd64
state: absent
- name: Add helm repo
shell: helm repo add rancher-latest {{ rancher_helm.rancher_chart }}
- name: Ensure rancher namespace exists
shell: kubectl create namespace cattle-system
- name: Install CRDs
shell: kubectl apply --validate=false -f {{ rancher_helm.cert_manager_crd }}
- name: Ensure cert-manager namespace exists
shell: kubectl create namespace cert-manager
- name: Add cert-manager helm repo
shell: helm repo add jetstack {{ rancher_helm.cert_manager_chart }}
- name: Update helm repos
shell: helm repo update
- name: Install helm chart
shell: helm install cert-manager jetstack/cert-manager --namespace cert-manager --version v1.0.4
- name: Wait for all cert-manager pods become created
shell: "kubectl get po --namespace=cert-manager --output=jsonpath='{.items[*].metadata.name}'"
register: cert_manager_pods_created
until: item in cert_manager_pods_created.stdout
retries: 10
delay: 30
with_items:
- cert-manager
- cert-manager-cainjector
- cert-manager-webhook
- name: Wait for cert-manager pods to become ready
shell: "kubectl wait --namespace=cert-manager --for=condition=Ready pods --all --timeout=600s"
register: cert_manager_pods_ready
- name: Install rancher
shell: helm install rancher rancher-latest/rancher --namespace cattle-system --set hostname={{ hostvars[groups['loadbalancer'][0]].node_fqdn if (k8s.control_plane.vms > 1) else rancher.ingress_hostname }}
- name: Wait for rancher deploy to end
shell: "kubectl -n cattle-system rollout status deploy/rancher"
register: rancher_rollout_succeeded
until: '"successfully rolled out" in rancher_rollout_succeeded.stdout'
retries: 10
delay: 30
- name: Wait for rancher pods to be ready
# shell: "kubectl wait --namespace=cattle-system --for=condition=Ready pods --all --timeout=600s"
shell: "kubectl wait --for=condition=available --timeout=600s deployment/rancher -n cattle-system"
when: rancher.install_rancher