rocky-docker-lxc/, caddy-vm/, monitoring-vm/ (was missing entirely -
Grafana+Loki+Prometheus stack, refreshed and CA mount stripped same as
everything else), and automation/{ansible,automation-vm,iac}/ for the
three repos that live on the automation VM. Hawser is genuinely
deployed on all three of caddy-vm/monitoring-vm/automation-vm so it's
duplicated in each rather than picking one canonical home.
Old Ansible/ and "Infrastrucutre as Code/" content moved under
automation/ansible/old-playbooks and automation/iac/old-content as-is
for now - contents still need refreshing against the current repos and
a per-folder README, that's the next pass.
57 lines
1.7 KiB
YAML
57 lines
1.7 KiB
YAML
---
|
|
- hosts: Docker
|
|
become: true
|
|
become_method: sudo
|
|
become_user: root
|
|
vars:
|
|
GOTIFY_IP: xxx #[Your gotify host IP goes here]
|
|
GOTIFY_PORT: xxx #[Your gotify port goes here]
|
|
GOTIFY_TOKEN: xxx #[Your app token goes here]
|
|
ansible_python_interpreter: /usr/bin/python3
|
|
|
|
tasks:
|
|
|
|
- name: prune non-dangling images
|
|
community.docker.docker_prune:
|
|
containers: false
|
|
images: true
|
|
images_filters:
|
|
dangling: false
|
|
networks: false
|
|
volumes: false
|
|
builder_cache: false
|
|
|
|
- name: Check if reboot is required
|
|
stat:
|
|
path: /var/run/reboot-required
|
|
register: reboot_required_file
|
|
|
|
- name: Show Output of required reboots
|
|
debug: msg="{{ reboot_required_file.stat.exists == true }}"
|
|
|
|
- name: Rebooting machine
|
|
shell: sleep 2 && shutdown -r now "Ansible updates triggered"
|
|
async: 1
|
|
poll: 0
|
|
ignore_errors: true
|
|
when: reboot_required_file.stat.exists
|
|
|
|
- name: Waiting for the machine to come back
|
|
local_action: wait_for host={{ ansible_host }} state=started port=22 delay=30
|
|
become: false
|
|
when: reboot_required_file.stat.exists
|
|
|
|
- name: notify via Gotify
|
|
uri:
|
|
url: 'http://{{ GOTIFY_IP }}:{{ GOTIFY_PORT }}/message?token={{ GOTIFY_TOKEN }}'
|
|
method: POST
|
|
body:
|
|
title:
|
|
content: clean docker hosts
|
|
message:
|
|
content: The clean docker playbook has completed for {{ ansible_host }} and is now updated. A required reboot is {{ reboot_required_file.stat.exists == true }}.
|
|
priority:
|
|
content: '5'
|
|
body_format: form-multipart
|
|
register: result
|
|
... |