This repository has been archived by the owner on Oct 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ansible.yaml
79 lines (66 loc) · 2.07 KB
/
ansible.yaml
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
---
version: "3"
env:
ANSIBLE_CONFIG: "{{.PROJECT_DIR}}/ansible.cfg"
vars:
ANSIBLE_PLAYBOOK_DIR: "{{.ANSIBLE_DIR}}/playbooks"
ANSIBLE_INVENTORY_DIR: "{{.ANSIBLE_DIR}}/inventory"
tasks:
init:
desc: Install / Upgrade Ansible galaxy deps
dir: ansible
cmds:
- ansible-galaxy install -r requirements.yaml -f
list:
desc: List all the hosts
dir: ansible
aliases: [hosts]
cmds:
- ansible all -i {{.ANSIBLE_INVENTORY_DIR}}/hosts.yaml --list-hosts
setup:
desc: Setup all the k8s nodes for running k3s
dir: ansible
cmds:
- ansible-playbook -i {{.ANSIBLE_INVENTORY_DIR}}/hosts.yaml {{.ANSIBLE_PLAYBOOK_DIR}}/setup.yaml
install:
desc: Install Kubernetes on the nodes
dir: ansible
cmds:
- ansible-playbook -i {{.ANSIBLE_INVENTORY_DIR}}/hosts.yaml {{.ANSIBLE_PLAYBOOK_DIR}}/install.yaml
status:
desc: Show k3s service status
dir: ansible
cmds:
- ansible-playbook -i {{.ANSIBLE_INVENTORY_DIR}}/hosts.yaml {{.ANSIBLE_PLAYBOOK_DIR}}/status.yaml
destroy:
desc: Uninstall Kubernetes on the nodes
dir: ansible
interactive: true
cmds:
- ansible-playbook -i {{.ANSIBLE_INVENTORY_DIR}}/hosts.yaml {{.ANSIBLE_PLAYBOOK_DIR}}/destroy.yaml
ping:
desc: Ping all the hosts
dir: ansible
cmds:
- ansible all -i {{.ANSIBLE_INVENTORY_DIR}}/hosts.yaml --one-line -m 'ping'
uptime:
desc: Uptime of all the hosts
dir: ansible
cmds:
- ansible all -i {{.ANSIBLE_INVENTORY_DIR}}/hosts.yaml --one-line -a 'uptime'
reboot:
desc: Reboot all the k8s nodes
dir: ansible
cmds:
- ansible-playbook -i {{.ANSIBLE_INVENTORY_DIR}}/hosts.yaml {{.ANSIBLE_PLAYBOOK_DIR}}/reboot.yaml
poweroff:
desc: Shutdown all the k8s nodes
dir: ansible
cmds:
- ansible kubernetes -i {{.ANSIBLE_INVENTORY_DIR}}/hosts.yaml -a '/usr/bin/systemctl poweroff' --become
update:
aliases: [upgrade]
desc: Update dependencies
dir: ansible
cmds:
- ansible-playbook -i {{.ANSIBLE_INVENTORY_DIR}}/hosts.yaml {{.ANSIBLE_PLAYBOOK_DIR}}/update.yaml