-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathnodes.yaml
More file actions
93 lines (80 loc) · 2.63 KB
/
Copy pathnodes.yaml
File metadata and controls
93 lines (80 loc) · 2.63 KB
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
---
- name: Install NanoPI Cluster
hosts: nodes
remote_user: dietpi
become: yes
gather_facts: yes
tasks:
- name: Disable root login by changing shell
user:
name: root
shell: /usr/sbin/nologin
- name: Update DietPi
command: /boot/dietpi/dietpi-update
- name: Install snapd with apt
apt:
name: snapd
state: present
- name: Install ceph with apt
apt:
name: ceph
state: present
- name: Ensure snapd service is running
service:
name: snapd
state: started
enabled: yes
- name: Install MicroK8s
command: snap install microk8s --classic
args:
creates: /snap/bin/microk8s
- name: Install microceph
command: snap install microceph --channel=latest/edge
args:
creates: /snap/bin/microceph
- name: Add the current user to the microk8s group
user:
name: dietpi
groups: microk8s
append: yes
# - name: Bootstrap Ceph
# command: microceph cluster bootstrap
# args:
# creates: /snap/bin/microceph
- name: Wait for MicroK8s to be ready
command: microk8s status --wait-ready
environment:
PATH: "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin"
become_user: dietpi
- name: Enable addons
command: |
microk8s enable dashboard
microk8s enable dns
microk8s enable helm
microk8s enable ingress
microk8s enable metallb
microk8s enable metrics-server
microk8s enable registry
microk8s enable rook-ceph
microk8s enable storage
when: inventory_hostname in groups['controllers']
environment:
PATH: "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin"
become_user: dietpi
delegate_to: "{{ groups['controllers'][0] }}"
run_once: true
- name: Generate join token on master node
ansible.builtin.shell: "microk8s add-node | grep microk8s | grep worker"
register: join_command_output
when: inventory_hostname in groups['controllers']
environment:
PATH: "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin"
delegate_to: "{{ master_node_hostname }}"
run_once: true
- name: Join cluster
when: not inventory_hostname in groups['controllers']
environment:
PATH: "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin"
ansible.builtin.shell: "{{ hostvars['controllers']['join_command_output']['stdout'] }}"
delegate_to: "{{ inventory_hostname }}"
run_once: true