Added some maintenance scripts
This commit is contained in:
parent
52396e1f8a
commit
b1d691ecdf
35
playbooks/maintenance/clean-proxies.yml
Normal file
35
playbooks/maintenance/clean-proxies.yml
Normal 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
|
13
playbooks/maintenance/disk-usage-report.yml
Normal file
13
playbooks/maintenance/disk-usage-report.yml
Normal 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') }}"
|
Loading…
x
Reference in New Issue
Block a user