Added some maintenance scripts

This commit is contained in:
Javier Feliz 2025-07-19 17:46:35 -04:00
parent 52396e1f8a
commit b1d691ecdf
2 changed files with 48 additions and 0 deletions

View File

@ -0,0 +1,35 @@
---
- name: Clean proxy VMs of left over build files and packages
hosts: proxies
become: true
tasks:
- name: Check Caddy binary location
ansible.builtin.command: which caddy
register: caddy_path
- name: Fail if Caddy is running from /root/go
ansible.builtin.fail:
msg: "Caddy is running from /root/go — aborting cleanup to avoid breaking it."
when: caddy_path.stdout.startswith('/root/go')
- name: Ensure go is installed (to use go clean)
ansible.builtin.command: which go
register: go_check
failed_when: go_check.rc != 0
changed_when: false
- name: Clean Go module and build cache
ansible.builtin.command: go clean -modcache -cache -testcache
environment:
HOME: /root
when: go_check.rc == 0
- name: Remove /root/go
ansible.builtin.file:
path: /root/go
state: absent
- name: Remove /root/.cache
ansible.builtin.file:
path: /root/.cache
state: absent

View File

@ -0,0 +1,13 @@
---
- name: Check disk usage across all nodes
hosts: vms
become: true
gather_facts: false
tasks:
- name: Get disk usage of root filesystem
ansible.builtin.shell: du -h -d1 --one-file-system / | sort -hr
register: disk_usage
- name: Print disk usage for {{ inventory_hostname }}
ansible.builtin.debug:
msg: "{{ inventory_hostname }} → {{ disk_usage.stdout_lines | join('\n') }}"