generated from onedr0p/cluster-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
10ae863
commit 5b71269
Showing
3 changed files
with
106 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
--- | ||
version: "3" | ||
|
||
env: | ||
ANSIBLE_CONFIG: "{{.PROJECT_DIR}}/ansible/ansible.cfg" | ||
|
||
vars: | ||
ANSIBLE_PLAYBOOK_DIR: "{{.ANSIBLE_DIR}}/playbooks" | ||
ANSIBLE_INVENTORY_DIR: "{{.ANSIBLE_DIR}}/inventory" | ||
|
||
tasks: | ||
deps: | ||
desc: Upgrade Ansible galaxy deps | ||
dir: ansible | ||
cmds: | ||
- "ansible-galaxy install -r requirements.yml --force" | ||
- "pip3 install -r requirements.txt" | ||
silent: true | ||
|
||
list: | ||
desc: List all the hosts | ||
dir: ansible | ||
cmds: | ||
- "ansible all -i {{.ANSIBLE_INVENTORY_DIR}}/home-cluster/hosts.yml --list-hosts" | ||
silent: true | ||
|
||
ping: | ||
desc: Ping all the hosts | ||
dir: ansible | ||
cmds: | ||
- "ansible all -i {{.ANSIBLE_INVENTORY_DIR}}/home-cluster/hosts.yml --one-line -m 'ping'" | ||
silent: true | ||
|
||
uptime: | ||
desc: Uptime of all the hosts | ||
dir: ansible | ||
cmds: | ||
- ansible all -i {{.ANSIBLE_INVENTORY_DIR}}/home-cluster/hosts.yml --one-line -a 'uptime' | ||
silent: true | ||
|
||
clean-images: | ||
desc: Clean up stale container images | ||
dir: ansible | ||
cmds: | ||
- "ansible kubernetes -i {{.ANSIBLE_INVENTORY_DIR}}/home-cluster/hosts.yml --one-line -a 'k3s crictl rmi --prune' --become" | ||
silent: true | ||
|
||
purge-manifests: | ||
desc: Delete all manifests under /var/lib/rancher/k3s/server/manifests | ||
dir: ansible | ||
cmds: | ||
- "ansible master -i {{.ANSIBLE_INVENTORY_DIR}}/home-cluster/hosts.yml --one-line -a 'rm /var/lib/rancher/k3s/server/manifests/*' --become" | ||
|
||
reboot: | ||
desc: Reboot all the k8s nodes | ||
dir: ansible | ||
cmds: | ||
- "ansible kubernetes -i {{.ANSIBLE_INVENTORY_DIR}}/home-cluster/hosts.yml -a '/usr/bin/systemctl reboot' --become" | ||
silent: true | ||
|
||
poweroff: | ||
desc: Shutdown all the k8s nodes | ||
dir: ansible | ||
cmds: | ||
- "ansible kubernetes -i {{.ANSIBLE_INVENTORY_DIR}}/home-cluster/hosts.yml -a '/usr/bin/systemctl poweroff' --become" | ||
silent: true | ||
|
||
playbook:debian-prepare: | ||
desc: Prepare all the k8s nodes for running k3s | ||
dir: ansible | ||
cmds: | ||
- "ansible-playbook -i {{.ANSIBLE_INVENTORY_DIR}}/home-cluster/hosts.yml {{.ANSIBLE_PLAYBOOK_DIR}}/kubernetes/debian-prepare.yml" | ||
silent: true | ||
|
||
playbook:debian-upgrade: | ||
desc: Upgrade all the k8s nodes operating system | ||
dir: ansible | ||
cmds: | ||
- "ansible-playbook -i {{.ANSIBLE_INVENTORY_DIR}}/home-cluster/hosts.yml {{.ANSIBLE_PLAYBOOK_DIR}}/kubernetes/debian-upgrade.yml" | ||
silent: true | ||
|
||
playbook:cluster-install: | ||
desc: Install Kubernetes on the nodes | ||
dir: ansible | ||
cmds: | ||
- "ansible-playbook -i {{.ANSIBLE_INVENTORY_DIR}}/home-cluster/hosts.yml {{.ANSIBLE_PLAYBOOK_DIR}}/kubernetes/k3s-install.yml" | ||
silent: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
--- | ||
- hosts: | ||
- storage | ||
become: true | ||
gather_facts: true | ||
any_errors_fatal: true | ||
tasks: | ||
- name: upgrade | ||
ansible.builtin.apt: | ||
upgrade: full | ||
update_cache: true | ||
cache_valid_time: 3600 | ||
autoclean: true | ||
autoremove: true | ||
register: apt_upgrade | ||
retries: 5 | ||
until: apt_upgrade is success |