76 lines
2.3 KiB
YAML
76 lines
2.3 KiB
YAML
---
|
|
version: "3"
|
|
|
|
env:
|
|
ANSIBLE_CONFIG: "{{.PROJECT_DIR}}/ansible.cfg"
|
|
K8S_AUTH_KUBECONFIG: "{{.PROJECT_DIR}}/kubeconfig"
|
|
|
|
vars:
|
|
ANSIBLE_PLAYBOOK_DIR: "{{.ANSIBLE_DIR}}/playbooks"
|
|
ANSIBLE_INVENTORY_DIR: "{{.ANSIBLE_DIR}}/inventory"
|
|
|
|
tasks:
|
|
|
|
init:
|
|
desc: Install / Upgrade Ansible galaxy deps
|
|
dir: "{{.ANSIBLE_DIR}}"
|
|
cmds:
|
|
- ansible-galaxy install -r requirements.yml --roles-path ~/.ansible/roles --force
|
|
- ansible-galaxy collection install -r requirements.yml --collections-path ~/.ansible/collections --force
|
|
|
|
list:
|
|
desc: List all the hosts
|
|
dir: "{{.ANSIBLE_DIR}}"
|
|
cmds:
|
|
- ansible all -i {{.ANSIBLE_INVENTORY_DIR}}/hosts.yml --list-hosts
|
|
|
|
prepare:
|
|
desc: Prepare all the k8s nodes for running k3s
|
|
dir: "{{.ANSIBLE_DIR}}"
|
|
cmds:
|
|
- ansible-playbook -i {{.ANSIBLE_INVENTORY_DIR}}/hosts.yml {{.ANSIBLE_PLAYBOOK_DIR}}/cluster-prepare.yml
|
|
|
|
install:
|
|
desc: Install Kubernetes on the nodes
|
|
dir: "{{.ANSIBLE_DIR}}"
|
|
cmds:
|
|
- ansible-playbook -i {{.ANSIBLE_INVENTORY_DIR}}/hosts.yml {{.ANSIBLE_PLAYBOOK_DIR}}/cluster-installation.yml
|
|
|
|
nuke:
|
|
desc: Uninstall Kubernetes on the nodes
|
|
dir: "{{.ANSIBLE_DIR}}"
|
|
interactive: true
|
|
cmds:
|
|
- ansible-playbook -i {{.ANSIBLE_INVENTORY_DIR}}/hosts.yml {{.ANSIBLE_PLAYBOOK_DIR}}/cluster-nuke.yml
|
|
- task: force-reboot
|
|
|
|
ping:
|
|
desc: Ping all the hosts
|
|
dir: "{{.ANSIBLE_DIR}}"
|
|
cmds:
|
|
- ansible all -i {{.ANSIBLE_INVENTORY_DIR}}/hosts.yml --one-line -m 'ping'
|
|
|
|
uptime:
|
|
desc: Uptime of all the hosts
|
|
dir: "{{.ANSIBLE_DIR}}"
|
|
cmds:
|
|
- ansible all -i {{.ANSIBLE_INVENTORY_DIR}}/hosts.yml --one-line -a 'uptime'
|
|
|
|
rollout-reboot:
|
|
desc: Rollout a reboot across all the k8s nodes
|
|
dir: "{{.ANSIBLE_DIR}}"
|
|
cmds:
|
|
- ansible-playbook -i {{.ANSIBLE_INVENTORY_DIR}}/hosts.yml {{.ANSIBLE_PLAYBOOK_DIR}}/cluster-rollout-reboot.yml
|
|
|
|
force-reboot:
|
|
desc: Reboot all the k8s nodes
|
|
dir: "{{.ANSIBLE_DIR}}"
|
|
cmds:
|
|
- ansible-playbook -i {{.ANSIBLE_INVENTORY_DIR}}/hosts.yml {{.ANSIBLE_PLAYBOOK_DIR}}/cluster-reboot.yml
|
|
|
|
force-poweroff:
|
|
desc: Shutdown all the k8s nodes
|
|
dir: "{{.ANSIBLE_DIR}}"
|
|
cmds:
|
|
- ansible kubernetes -i {{.ANSIBLE_INVENTORY_DIR}}/hosts.yml -a '/usr/bin/systemctl poweroff' --become
|