forked from geerlingguy/turing-pi-2-cluster
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.yml
123 lines (99 loc) · 2.78 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
---
- name: Set up cluster-wide configuration.
hosts: cluster
gather_facts: false
become: true
handlers:
- name: reboot-pi
reboot:
vars_files:
- config.yml
tasks:
- name: Ensure cgroups are configured correctly in cmdline.txt.
ansible.builtin.replace:
path: /boot/cmdline.txt
regexp: '^([\w](?!.*\b{{ item }}\b).*)$'
replace: '\1 {{ item }}'
with_items:
- "cgroup_memory=1"
- "cgroup_enable=memory"
notify: reboot-pi
- name: Download K3s install script.
ansible.builtin.get_url:
url: https://get.k3s.io
dest: "~/k3s_install.sh"
mode: a+x
- name: Configure storage node (node 3).
hosts: storage
gather_facts: false
become: true
vars_files:
- config.yml
tasks:
- name: Set up storage.
include_tasks: tasks/storage.yml
when: storage_configure
- name: Configure the control plane (node 1).
hosts: control_plane
gather_facts: false
become: true
vars_files:
- config.yml
tasks:
- name: Install K3s on control plane (takes a while).
ansible.builtin.shell: >-
~/k3s_install.sh >> ~/k3s_install_log.txt
args:
chdir: "~"
creates: /var/lib/rancher/k3s/server/node-token
- name: Get node token.
ansible.builtin.command: cat /var/lib/rancher/k3s/server/node-token
changed_when: false
register: node_token_output
- name: Set node_token fact.
ansible.builtin.set_fact:
node_token: "{{ node_token_output.stdout_lines[0] }}"
- name: Ensure required dependencies are installed.
package:
name:
- python3-pip
- python3-setuptools
- build-essential
- golang
- git
state: present
become: true
- name: Ensure required Python libraries are installed.
pip:
name:
- openshift
- pyyaml
state: present
become: true
- name: Configure the nodes (nodes 2-4).
hosts: nodes
gather_facts: false
become: true
vars_files:
- config.yml
tasks:
- name: Install K3s on nodes (takes a while).
ansible.builtin.shell: >-
K3S_URL=https://"{{ groups['control_plane'][0] }}":6443
K3S_TOKEN="{{ hostvars[groups['control_plane'][0]]['node_token'] }}"
~/k3s_install.sh >> ~/k3s_install_log.txt
args:
chdir: "~"
creates: /var/lib/rancher/k3s/agent/kubelet.kubeconfig
- name: Set up Helm.
import_playbook: tasks/kubernetes/helm.yml
tags: ['helm']
- name: Set up NFS PVCs.
import_playbook: tasks/kubernetes/nfs.yml
tags: ['nfs']
- name: Set up Prometheus.
import_playbook: tasks/kubernetes/prometheus.yml
tags: ['prometheus']
- name: Set up Drupal.
import_playbook: tasks/kubernetes/drupal.yml
tags: ['drupal']