Compare commits

...
15 Commits
Author SHA1 Message Date
JustinandClaude Opus 5.5 f22821d168 Docker: remove commanfeed from nightly stack update (stack retired)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-27 19:42:34 -06:00
JustinandClaude Opus 5.5 7dcc71d88c Docker: add gaseous, audio-book, commanfeed to nightly stack update
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-27 19:22:34 -06:00
JustinandClaude Opus 5.5 622325f210 Add playbook to remove PatchMon agent from Windows hosts
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-22 22:30:18 -06:00
JustinandClaude Opus 5.5 ef7047f6bc Add playbook to remove PatchMon agent (patch server retired)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-22 22:27:15 -06:00
Justin fa0bd81dd2 updated the docker file 2026-11-22 10:07:44 -06:00
JustinandClaude Opus 5.5 e03183d58f Ubuntu: remove maint-reboot.yaml, replaced by reboot.yaml
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-19 19:58:09 -06:00
JustinandClaude Opus 5.5 fb54627f38 Ubuntu: reboot only servers that need it, one at a time
Rewrite reboot.yaml to reboot ubuntu_servers flagged with
/run/reboot-required: pi-hole first, the rest one at a time, and the
Ansible controller last, with a ntfy alert per server. Parallel boots
overloaded the Proxmox host and services timed out at boot.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-19 19:57:06 -06:00
JustinandClaude Opus 5.5 84433d5cbc Beszel: fail on silent update failures and crashed agents
- Windows: fail if a scoop update ran but the agent version didn't change
- Ubuntu: after restarting an upgraded agent, check it is still active

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-17 15:38:08 -06:00
JustinandClaude Opus 5.5 abdca77860 Windows: report from a post-install search, even on failure
- Re-search after installing; win_updates can list reboot-applied updates as not installed
- Wrap install in block/always so the pending report runs when an update fails
- Read reboot status from the post-install search

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-17 15:32:00 -06:00
JustinandClaude Opus 5.5 8de2386aa1 Ubuntu: streamline nightly update playbook
- Merge proxmox and hardware plays into one play
- Replace serial: 1 with throttle: 1 so an unreachable host no longer aborts the run
- Restart qemu-guest-agent only via handler when the package changes
- Combine cache update, upgrade, autoremove and autoclean into one apt task
- Move net-tools install to inst-vm-core.yaml

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-17 15:29:43 -06:00
JustinandClaude Opus 5.5 011d427182 Windows: add Beszel agent update playbook; tolerate pending-restart blocks
- windows/update-beszel.yaml: scoop update of beszel-agent with NSSM service stop/start
- windows/update.yaml: with reboot=false, don't fail on updates blocked by a pending
  restart (WU_E_INSTALL_NOT_ALLOWED); report installed vs not installed

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-12 20:58:35 -06:00
JustinandClaude Opus 5.5 fe3119cfaf Add Beszel and Windows update playbooks; use vault password file
- ubuntu/update-beszel.yaml: upgrade Beszel hub on killer2 and agents on ubuntu_servers
- windows/update.yaml: install Windows Updates on [windows] group, reboot if needed
- ansible.cfg: point vault_password_file at ~/.ansible/vault_pass

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-12 19:35:29 -06:00
JustinandClaude Opus 5.5 2b2a56dbca Remove patchman-remove playbook
Patchman client has been removed from all servers; the cleanup
playbook is no longer needed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 20:56:25 -06:00
JustinandClaude Opus 5.5 5752e877cb Remove patchman_client role and install playbook
Patchman has been uninstalled from all servers and patch.ki5bhv.com
taken out of the inventory. Keep patchman-remove.yaml for cleanup.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 20:53:30 -06:00
JustinandClaude Opus 5.5 4aeb08ab1f Add patchman-remove playbook; re-enable nightly update and reboot cron jobs
- patchman-remove.yaml: uninstall patchman-client from ubuntu_servers
  (cron entry, script, /etc/patchman); leaves curl/jq/cron in place
- crontab.txt: uncomment the 2:00 update.yaml and 7:00 reboot.yaml jobs

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 20:51:31 -06:00
19 changed files with 430 additions and 1750 deletions

No files matched your search

+1
View File
@@ -1,4 +1,5 @@
[defaults] [defaults]
vault_password_file = /home/justin/.ansible/vault_pass
# (boolean) By default, Ansible will issue a warning when received from a task action (module or action plugin). # (boolean) By default, Ansible will issue a warning when received from a task action (module or action plugin).
# These warnings can be silenced by adjusting this setting to False. # These warnings can be silenced by adjusting this setting to False.
;action_warnings=True ;action_warnings=True
+2 -2
View File
@@ -28,7 +28,7 @@ ANSIBLE_CONFIG=/home/justin/Ansible/ansible.cfg
0 5 * * * ansible-playbook /home/justin/Ansible/docker/update-docker-compose.yaml >> /home/justin/cron-logs/update-docker-compose.log 2>&1 0 5 * * * ansible-playbook /home/justin/Ansible/docker/update-docker-compose.yaml >> /home/justin/cron-logs/update-docker-compose.log 2>&1
30 5 * * * ansible-playbook /home/justin/Ansible/docker/restart-qtorrnt.yaml >> /home/justin/cron-logs/restart-qtorrnt.log 2>&1 30 5 * * * ansible-playbook /home/justin/Ansible/docker/restart-qtorrnt.yaml >> /home/justin/cron-logs/restart-qtorrnt.log 2>&1
0 6 * * * ansible-playbook /home/justin/Ansible/ubuntu/restart-beszel.yaml >> /home/justin/cron-logs/restart-beszel.log 2>&1 0 6 * * * ansible-playbook /home/justin/Ansible/ubuntu/restart-beszel.yaml >> /home/justin/cron-logs/restart-beszel.log 2>&1
#0 2 * * * ansible-playbook /home/justin/Ansible/ubuntu/update.yaml >> /home/justin/cron-logs/update.log 2>&1 0 2 * * * ansible-playbook /home/justin/Ansible/ubuntu/update.yaml >> /home/justin/cron-logs/update.log 2>&1
#0 7 * * * ansible-playbook /home/justin/Ansible/ubuntu/reboot.yaml >> /home/justin/cron-logs/reboot.log 2>&1 0 7 * * * ansible-playbook /home/justin/Ansible/ubuntu/reboot.yaml >> /home/justin/cron-logs/reboot.log 2>&1
0 5 * * 2 ansible-playbook /home/justin/Ansible/ubuntu/maint-clean-logs-cache.yaml >> /home/justin/cron-logs/maint-clean-logs-cache.log 2>&1 0 5 * * 2 ansible-playbook /home/justin/Ansible/ubuntu/maint-clean-logs-cache.yaml >> /home/justin/cron-logs/maint-clean-logs-cache.log 2>&1
0 0 1,15 * * ansible-playbook /home/justin/Ansible/ubuntu/fix-ssh-host-keys.yaml >> /home/justin/cron-logs/fix-ssh-host-keys.log 2>&1 0 0 1,15 * * ansible-playbook /home/justin/Ansible/ubuntu/fix-ssh-host-keys.yaml >> /home/justin/cron-logs/fix-ssh-host-keys.log 2>&1
+56 -339
View File
@@ -1,309 +1,57 @@
--- ---
- name: Deploy Docker Compose stack with pull and restart # Nightly: pull and recreate Docker Compose stacks, then prune unused images.
hosts: killer2.ki5bhv.com # Add or remove a stack by editing the list for its host below.
#
# A stack that still fails after retries does not stop the rest of that
# host's stacks or the other hosts. Failures are listed at the end and
# mark the host as failed in the recap.
- name: Update Docker Compose stacks
hosts: killer2.ki5bhv.com:docker.ki5bhv.com:proxy-server.ki5bhv.com
become: true become: true
vars:
stacks_by_host:
killer2.ki5bhv.com:
- /home/justin/docker/qbits
- /home/justin/docker/homarr
- /home/justin/docker/wireguard
- /home/justin/docker/beszel
- /home/justin/docker/cup
- /home/justin/docker/ntfy
- /home/justin/docker/vaultwarden
- /home/justin/docker/uptime-kuma
- /home/justin/docker/overseerr
- /home/justin/docker/portainer
- /home/justin/docker/it-tools
- /home/justin/docker/termix
- /home/justin/docker/netalertx
- /home/justin/docker/wavelog
- /home/justin/docker/kometa
- /home/justin/docker/tautulli
- /home/justin/docker/gaseous
docker.ki5bhv.com: # capital D on this host
- /home/justin/Docker/code-server
- /home/justin/Docker/audio-book
# Not listed on purpose: windows and minecraft are kept stopped
# ("created"), and an update would start them.
proxy-server.ki5bhv.com:
- /home/justin/docker/nginx-proxy
stacks: "{{ stacks_by_host[inventory_hostname] | default([]) }}"
tasks: tasks:
- name: Qbits - name: Pull and recreate stack
community.docker.docker_compose_v2: community.docker.docker_compose_v2:
project_src: /home/justin/docker/qbits project_src: "{{ item }}"
pull: always pull: always
recreate: auto recreate: auto
register: result loop: "{{ stacks }}"
loop_control:
label: "{{ item | basename }}"
pause: 1
register: stack_results
retries: 3 retries: 3
delay: 3 delay: 5
until: result is not failed until: stack_results is not failed
ignore_errors: true
- name: Pause
ansible.builtin.pause:
seconds: 1
- name: homarr
community.docker.docker_compose_v2:
project_src: /home/justin/docker/homarr/
pull: always
recreate: auto
- name: Pause
ansible.builtin.pause:
seconds: 1
- name: wireguard
community.docker.docker_compose_v2:
project_src: /home/justin/docker/wireguard/
pull: always
recreate: auto
- name: Pause
ansible.builtin.pause:
seconds: 1
- name: beszel
community.docker.docker_compose_v2:
project_src: /home/justin/docker/beszel/
pull: always
recreate: auto
- name: Pause
ansible.builtin.pause:
seconds: 1
- name: cup
community.docker.docker_compose_v2:
project_src: /home/justin/docker/cup/
pull: always
recreate: auto
- name: Pause
ansible.builtin.pause:
seconds: 1
- name: ntfy
community.docker.docker_compose_v2:
project_src: /home/justin/docker/ntfy/
pull: always
recreate: auto
- name: Pause
ansible.builtin.pause:
seconds: 1
- name: vaultwarden
community.docker.docker_compose_v2:
project_src: /home/justin/docker/vaultwarden/
pull: always
recreate: auto
- name: Pause
ansible.builtin.pause:
seconds: 1
- name: uptime-kuma
community.docker.docker_compose_v2:
project_src: /home/justin/docker/uptime-kuma/
pull: always
recreate: auto
- name: Pause
ansible.builtin.pause:
seconds: 1
- name: overseerr
community.docker.docker_compose_v2:
project_src: /home/justin/docker/overseerr/
pull: always
recreate: auto
- name: Pause
ansible.builtin.pause:
seconds: 1
- name: portainer
community.docker.docker_compose_v2:
project_src: /home/justin/docker/portainer/
pull: always
recreate: auto
- name: Pause
ansible.builtin.pause:
seconds: 1
- name: it-tools
community.docker.docker_compose_v2:
project_src: /home/justin/docker/it-tools/
pull: always
recreate: auto
- name: Pause
ansible.builtin.pause:
seconds: 1
- name: termix
community.docker.docker_compose_v2:
project_src: /home/justin/docker/termix/
pull: always
recreate: auto
- name: Pause
ansible.builtin.pause:
seconds: 1
- name: ntfy
community.docker.docker_compose_v2:
project_src: /home/justin/docker/ntfy/
pull: always
recreate: auto
- name: Pause
ansible.builtin.pause:
seconds: 1
- name: netalertx
community.docker.docker_compose_v2:
project_src: /home/justin/docker/netalertx/
pull: always
recreate: auto
- name: Pause
ansible.builtin.pause:
seconds: 1
- name: homarr
community.docker.docker_compose_v2:
project_src: /home/justin/docker/homarr/
pull: always
recreate: auto
- name: Pause
ansible.builtin.pause:
seconds: 1
- name: wireguard
community.docker.docker_compose_v2:
project_src: /home/justin/docker/wireguard/
pull: always
recreate: auto
- name: Pause
ansible.builtin.pause:
seconds: 1
- name: beszel
community.docker.docker_compose_v2:
project_src: /home/justin/docker/beszel/
pull: always
recreate: auto
- name: Pause
ansible.builtin.pause:
seconds: 1
- name: cup
community.docker.docker_compose_v2:
project_src: /home/justin/docker/cup/
pull: always
recreate: auto
- name: Pause
ansible.builtin.pause:
seconds: 1
- name: ntfy
community.docker.docker_compose_v2:
project_src: /home/justin/docker/ntfy/
pull: always
recreate: auto
- name: Pause
ansible.builtin.pause:
seconds: 1
- name: vaultwarden
community.docker.docker_compose_v2:
project_src: /home/justin/docker/vaultwarden/
pull: always
recreate: auto
- name: Pause
ansible.builtin.pause:
seconds: 1
- name: uptime-kuma
community.docker.docker_compose_v2:
project_src: /home/justin/docker/uptime-kuma/
pull: always
recreate: auto
- name: Pause
ansible.builtin.pause:
seconds: 1
- name: overseerr
community.docker.docker_compose_v2:
project_src: /home/justin/docker/overseerr/
pull: always
recreate: auto
- name: Pause
ansible.builtin.pause:
seconds: 1
- name: portainer
community.docker.docker_compose_v2:
project_src: /home/justin/docker/portainer/
pull: always
recreate: auto
- name: Pause
ansible.builtin.pause:
seconds: 1
- name: it-tools
community.docker.docker_compose_v2:
project_src: /home/justin/docker/it-tools/
pull: always
recreate: auto
- name: Pause
ansible.builtin.pause:
seconds: 1
- name: termix
community.docker.docker_compose_v2:
project_src: /home/justin/docker/termix/
pull: always
recreate: auto
- name: Pause
ansible.builtin.pause:
seconds: 1
- name: ntfy
community.docker.docker_compose_v2:
project_src: /home/justin/docker/ntfy/
pull: always
recreate: auto
- name: Pause
ansible.builtin.pause:
seconds: 1
- name: netalertx
community.docker.docker_compose_v2:
project_src: /home/justin/docker/netalertx/
pull: always
recreate: auto
- name: Pause
ansible.builtin.pause:
seconds: 1
- name: Wavelog
community.docker.docker_compose_v2:
project_src: /home/justin/docker/wavelog/
pull: always
recreate: auto
- name: Pause
ansible.builtin.pause:
seconds: 1
- name: Kometa
community.docker.docker_compose_v2:
project_src: /home/justin/docker/kometa/
pull: always
recreate: auto
- name: Pause
ansible.builtin.pause:
seconds: 1
- name: Tautulli
community.docker.docker_compose_v2:
project_src: /home/justin/docker/tautulli/
pull: always
recreate: auto
- name: Prune non-dangling images - name: Prune non-dangling images
community.docker.docker_prune: community.docker.docker_prune:
@@ -315,43 +63,12 @@
volumes: false volumes: false
builder_cache: false builder_cache: false
- name: Deploy Docker Compose stack with pull and restart - name: Fail if any stack did not update
hosts: docker.ki5bhv.com vars:
become: true failed_stacks: >-
tasks: {{ stack_results.results | selectattr('failed', 'defined')
| selectattr('failed') | map(attribute='item')
- name: code | map('basename') | list }}
community.docker.docker_compose_v2: ansible.builtin.fail:
project_src: /home/justin/Docker/code-server msg: "Stacks that failed to update: {{ failed_stacks | join(', ') }}"
pull: always when: failed_stacks | length > 0
recreate: auto
- 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: Deploy Docker Compose stack with pull and restart
hosts: proxy-server.ki5bhv.com
become: true
tasks:
- name: nginx proxy
community.docker.docker_compose_v2:
project_src: /home/justin/docker/nginx-proxy
pull: always
recreate: auto
- name: Prune non-dangling images
community.docker.docker_prune:
containers: false
images: true
images_filters:
dangling: false
networks: false
volumes: false
builder_cache: false
-8
View File
@@ -1,8 +0,0 @@
---
# Installs patchman-client on every Ubuntu server and enrolls it with the
# Patchman server on patch.ki5bhv.com. Role settings: roles/patchman_client/defaults/main.yml
- name: Install and enroll patchman-client
hosts: ubuntu_servers
become: true
roles:
- patchman_client
-23
View File
@@ -1,23 +0,0 @@
---
# Patchman server URL, including the /patchman path.
# Clients must be in a network allowed to upload (192.168.1.0/24 by default).
patchman_server_url: "http://192.168.1.8/patchman"
# Comma or space delimited tags shown on the host in Patchman.
patchman_client_tags: "Server"
# Options passed to curl when uploading.
patchman_client_curl_options: "--insecure --connect-timeout 60 --max-time 300"
# Report protocol: 1 = text, 2 = json (needs jq and, by default, an API key).
patchman_client_protocol: 1
patchman_client_api_key: ""
# Daily report schedule. The minute is derived from the hostname so servers
# don't all report at the same moment, but stays stable between runs.
patchman_cron_enabled: true
patchman_cron_hour: "2"
patchman_cron_minute: "{{ 59 | random(seed=inventory_hostname) }}"
# Send a report right away when the client is installed or its config changes.
patchman_report_on_change: true
File diff suppressed because it is too large. Load diff
-5
View File
@@ -1,5 +0,0 @@
---
- name: Send patchman report
ansible.builtin.command: /usr/sbin/patchman-client
changed_when: true
when: patchman_report_on_change | bool
-54
View File
@@ -1,54 +0,0 @@
---
- name: Install client dependencies
ansible.builtin.package:
name: "{{ ['curl'] + (['jq'] if patchman_client_protocol | int == 2 else []) }}"
state: present
- name: Install cron
ansible.builtin.package:
name: "{{ 'cron' if ansible_facts['os_family'] == 'Debian' else 'cronie' }}"
state: present
when: patchman_cron_enabled | bool
- name: Install patchman-client script
ansible.builtin.copy:
src: patchman-client
dest: /usr/sbin/patchman-client
owner: root
group: root
mode: "0755"
notify: Send patchman report
- name: Create /etc/patchman
ansible.builtin.file:
path: /etc/patchman
state: directory
owner: root
group: root
mode: "0755"
- name: Configure patchman-client
ansible.builtin.template:
src: patchman-client.conf.j2
dest: /etc/patchman/patchman-client.conf
owner: root
group: root
# keep the file private when it holds an API key
mode: "{{ '0600' if patchman_client_api_key else '0644' }}"
notify: Send patchman report
# Writes the whole file so it replaces any hand-made /etc/cron.d/patchman-client
- name: Schedule daily patchman report
ansible.builtin.template:
src: patchman-client.cron.j2
dest: /etc/cron.d/patchman-client
owner: root
group: root
mode: "0644"
when: patchman_cron_enabled | bool
- name: Remove daily patchman report schedule
ansible.builtin.file:
path: /etc/cron.d/patchman-client
state: absent
when: not patchman_cron_enabled | bool
@@ -1,24 +0,0 @@
# {{ ansible_managed }}
# Patchman server
server={{ patchman_server_url }}
# Options to curl
curl_options="{{ patchman_client_curl_options }}"
# Comma or space delimited tags to send
tags="{{ patchman_client_tags }}"
# Does the client output a report of the upload (e.g. for cronjob output)
report=false
# Protocol version (1 = text, 2 = json)
# Protocol 2 requires jq to be installed
protocol={{ patchman_client_protocol }}
# API key for protocol 2 authentication
{% if patchman_client_api_key %}
api_key={{ patchman_client_api_key }}
{% else %}
#api_key=pm_your_api_key_here
{% endif %}
@@ -1,6 +0,0 @@
# {{ ansible_managed }}
# Send a daily package report to the Patchman server ({{ patchman_server_url }})
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
{{ patchman_cron_minute }} {{ patchman_cron_hour }} * * * root /usr/sbin/patchman-client 2>&1 | logger -t patchman-client
+1
View File
@@ -10,6 +10,7 @@
- prometheus-node-exporter - prometheus-node-exporter
- nfs-common - nfs-common
- qemu-guest-agent - qemu-guest-agent
- net-tools
update_cache: true update_cache: true
- name: Start guest qemu-guest-agent - name: Start guest qemu-guest-agent
-9
View File
@@ -1,9 +0,0 @@
---
- name: Reboot machine
hosts: ["mqtt-server.ki5bhv.com", "git-server.ki5bhv.com", "webhost.ki5bhv.com", "clouflare.ki5bhv.com", "coding.ki5bhv.com",pi-hole-server.ki5bhv.com, "killer2.ki5bhv.com"]
become: true
tasks:
- name: Reboot machine
ansible.builtin.reboot:
reboot_timeout: 3600
+80 -9
View File
@@ -1,17 +1,88 @@
--- ---
- name: Rebooting Machines Proxmox # Reboot Ubuntu servers that have /run/reboot-required set, with a ntfy alert per server.
hosts: proxmox # Order: pi-hole (DNS) first and alone, then the rest a few at a time, then this
become: true # Ansible controller last, so it never reboots out from under the run.
# The hostnames for the DNS server and the controller are also in the play patterns below.
tasks: - name: Find servers that need a reboot
- name: Checking Reboot is needed hosts: ubuntu_servers
become: true become: true
gather_facts: false
tasks:
- name: Check for the reboot-required flag
ansible.builtin.stat: ansible.builtin.stat:
path: /run/reboot-required path: /run/reboot-required
register: reboot_required register: reboot_required
- name: Reboot Machine - name: Group servers that need a reboot
become: true ansible.builtin.group_by:
ansible.builtin.reboot: key: needs_reboot
reboot_timeout: 3600
when: reboot_required.stat.exists when: reboot_required.stat.exists
- name: Reboot servers
hosts: needs_reboot:!ansible.ki5bhv.com
become: true
gather_facts: false
vars:
dns_server: pi-hole-server.ki5bhv.com
ntfy_url: https://ntfy.ki5bhv.com/server
tasks:
- name: Reboot and notify
block:
# Runs on its own before anything else, so the other servers boot with DNS available.
- name: Reboot DNS server first
ansible.builtin.reboot:
reboot_timeout: 1800
when: inventory_hostname == dns_server
- name: Reboot remaining servers
ansible.builtin.reboot:
reboot_timeout: 1800
when: inventory_hostname != dns_server
throttle: 1 # one at a time: parallel boots overload the Proxmox host and services time out
- name: Notify reboot succeeded
ansible.builtin.uri:
url: "{{ ntfy_url }}"
method: POST
body: "{{ inventory_hostname }} needed a reboot and was rebooted"
delegate_to: localhost
become: false
rescue:
- name: Notify reboot failed
ansible.builtin.uri:
url: "{{ ntfy_url }}"
method: POST
body: "{{ inventory_hostname }} needed a reboot but it FAILED - check reboot.log"
headers:
Priority: high
delegate_to: localhost
become: false
- name: Mark host as failed
ansible.builtin.fail:
msg: "Reboot of {{ inventory_hostname }} failed"
- name: Reboot this Ansible controller last
hosts: needs_reboot:&ansible.ki5bhv.com
become: true
gather_facts: false
vars:
ntfy_url: https://ntfy.ki5bhv.com/server
tasks:
# Sent first: once the reboot happens, nothing is left to report back.
- name: Notify controller reboot
ansible.builtin.uri:
url: "{{ ntfy_url }}"
method: POST
body: "{{ inventory_hostname }} (Ansible controller) needed a reboot and is rebooting in 1 minute"
delegate_to: localhost
become: false
# The reboot module can't wait for the machine it is running on, so schedule it
# a minute out and let this run finish and write its log first.
- name: Schedule reboot in 1 minute
ansible.builtin.command:
argv: [shutdown, -r, "+1", "Ansible - reboot required"]
changed_when: true
+36
View File
@@ -0,0 +1,36 @@
---
# Remove the PatchMon agent (server patch.ki5bhv.com / 192.168.1.8 was retired).
- name: Remove PatchMon agent
hosts: linux
become: true
tasks:
- name: Check for PatchMon unit
ansible.builtin.stat:
path: /etc/systemd/system/patchmon-agent.service
register: patchmon_unit
- name: Stop and disable patchmon-agent
ansible.builtin.systemd_service:
name: patchmon-agent
state: stopped
enabled: false
when: patchmon_unit.stat.exists
- name: Find PatchMon cron entries
ansible.builtin.find:
paths: /etc/cron.d
patterns: "patchmon*"
register: patchmon_cron
- name: Remove PatchMon files
ansible.builtin.file:
path: "{{ item }}"
state: absent
loop: "{{ ['/etc/systemd/system/patchmon-agent.service', '/usr/local/bin/patchmon-agent', '/etc/patchmon']
+ (patchmon_cron.files | map(attribute='path') | list) }}"
register: patchmon_removed
- name: Reload systemd
ansible.builtin.systemd_service:
daemon_reload: true
when: patchmon_removed is changed
+79
View File
@@ -0,0 +1,79 @@
---
# Upgrade Beszel: hub (docker compose on killer2) first, then agents on all ubuntu_servers.
# Agents are the systemd binary at /opt/beszel-agent; uses the agent's built-in self-updater.
- name: Upgrade Beszel hub
hosts: killer2.ki5bhv.com
become: true
tasks:
- name: Pull and recreate beszel compose stack
community.docker.docker_compose_v2:
project_src: /home/justin/docker/beszel/
pull: always
recreate: auto
register: hub
retries: 3
delay: 3
until: hub is not failed
- name: Upgrade Beszel agents
hosts: ubuntu_servers
become: true
vars:
agent_bin: /opt/beszel-agent/beszel-agent
tasks:
- name: Check agent binary exists
ansible.builtin.stat:
path: "{{ agent_bin }}"
register: agent_stat
- name: Skip hosts without the binary agent
ansible.builtin.meta: end_host
when: not agent_stat.stat.exists
- name: Get current version
ansible.builtin.command: "{{ agent_bin }} -v"
register: before
changed_when: false
- name: Run self-update
ansible.builtin.command: "{{ agent_bin }} update"
register: update_out
changed_when: false
- name: Get new version
ansible.builtin.command: "{{ agent_bin }} -v"
register: after
changed_when: before.stdout != after.stdout
- name: Fix ownership
ansible.builtin.file:
path: /opt/beszel-agent
owner: beszel
group: beszel
recurse: true
- name: Restart beszel-agent
ansible.builtin.systemd:
name: beszel-agent
state: restarted
when: before.stdout != after.stdout
# systemd reports success as soon as the process starts; make sure the new
# version didn't crash right after.
- name: Verify beszel-agent stayed running
when: before.stdout != after.stdout
block:
- name: Give the agent time to start
ansible.builtin.wait_for:
timeout: 10
- name: Check beszel-agent is active
ansible.builtin.command: systemctl is-active beszel-agent
register: agent_active
changed_when: false
failed_when: agent_active.stdout != 'active'
- name: Report
ansible.builtin.debug:
msg: "{{ before.stdout }} -> {{ after.stdout }}"
+26 -56
View File
@@ -1,72 +1,42 @@
--- ---
- name: Proxmox Update and upgrade apt packages - name: Update and upgrade apt packages
hosts: proxmox hosts: proxmox:hardware
become: yes become: true
serial: 1 gather_subset: [min]
tasks: handlers:
- name: Restart qemu-guest-agent
- name: Update packages with apt
when: ansible_facts['pkg_mgr'] == 'apt'
ansible.builtin.apt:
update_cache: true
cache_valid_time: 3600
lock_timeout: 600
- name: Installing proxmox guest agent
when: ansible_facts['pkg_mgr'] == 'apt'
ansible.builtin.apt:
name: qemu-guest-agent
state: latest
- name: Enable and restart proxmox agent
ansible.builtin.service: ansible.builtin.service:
name: qemu-guest-agent name: qemu-guest-agent
state: restarted state: restarted
- name: Upgrade packages with apt
when: ansible_facts['pkg_mgr'] == 'apt'
ansible.builtin.apt:
upgrade: dist
- name: Clean up packages with apt
when: ansible_facts['pkg_mgr'] == 'apt'
ansible.builtin.apt:
autoclean: true
autoremove: true
- name: Hardware Update and upgrade apt packages
hosts: hardware
become: yes
tasks: tasks:
- name: Apt maintenance
- name: Update packages with apt
when: ansible_facts['pkg_mgr'] == 'apt' when: ansible_facts['pkg_mgr'] == 'apt'
block:
- name: Ensure qemu-guest-agent is installed
when: inventory_hostname in groups['proxmox']
ansible.builtin.apt: ansible.builtin.apt:
name: qemu-guest-agent
state: present
update_cache: true update_cache: true
cache_valid_time: 3600 cache_valid_time: 3600
lock_timeout: 600 lock_timeout: 600
notify: Restart qemu-guest-agent
- name: Upgrade packages with apt - name: Ensure qemu-guest-agent is running
when: ansible_facts['pkg_mgr'] == 'apt' when: inventory_hostname in groups['proxmox']
ansible.builtin.service:
name: qemu-guest-agent
state: started
- name: Upgrade packages and clean up
ansible.builtin.apt: ansible.builtin.apt:
update_cache: true
cache_valid_time: 3600
upgrade: dist upgrade: dist
- name: Clean up packages with apt
when: ansible_facts['pkg_mgr'] == 'apt'
ansible.builtin.apt:
autoclean: true
autoremove: true autoremove: true
autoclean: true
- name: installing net-tools on all lock_timeout: 600
hosts: all # One host at a time, but an unreachable host no longer aborts the run like serial: 1 did
become: yes throttle: 1
tasks:
- name: running apt
when: ansible_facts['pkg_mgr'] == 'apt'
ansible.builtin.apt:
name: net-tools
state: latest
+17
View File
@@ -0,0 +1,17 @@
---
# Remove the PatchMon agent (server patch.ki5bhv.com / 192.168.1.8 was retired).
- name: Remove PatchMon agent (Windows)
hosts: windows
tasks:
- name: Stop and delete PatchMonAgent service
ansible.windows.win_service:
name: PatchMonAgent
state: absent
- name: Remove PatchMon folders
ansible.windows.win_file:
path: "{{ item }}"
state: absent
loop:
- C:\Program Files\PatchMon
- C:\ProgramData\PatchMon
+59
View File
@@ -0,0 +1,59 @@
---
# Upgrade the Beszel agent on Windows hosts.
# Agent is installed with scoop (in the login user's profile) and run as an NSSM service "beszel-agent".
# Service is stopped during the update because Windows locks the running exe.
- name: Upgrade Beszel agent (Windows)
hosts: windows
gather_facts: false
vars:
scoop: 'C:\Users\Justin\scoop\shims\scoop.ps1'
agent_exe: 'C:\Users\Justin\scoop\shims\beszel-agent.exe'
service: beszel-agent
tasks:
- name: Get current version
ansible.windows.win_command: '"{{ agent_exe }}" -v'
register: before
changed_when: false
- name: Update scoop buckets
ansible.windows.win_shell: '& "{{ scoop }}" update'
changed_when: false
- name: Check whether an update is available
ansible.windows.win_shell: '& "{{ scoop }}" status 2>&1 | Out-String'
register: status
changed_when: false
- name: Update agent
when: "'beszel-agent' in status.stdout"
block:
- name: Stop service
ansible.windows.win_service:
name: "{{ service }}"
state: stopped
- name: Scoop update beszel-agent
ansible.windows.win_shell: '& "{{ scoop }}" update beszel-agent 2>&1 | Out-String'
register: upd
always:
- name: Start service
ansible.windows.win_service:
name: "{{ service }}"
state: started
- name: Get new version
ansible.windows.win_command: '"{{ agent_exe }}" -v'
register: after
changed_when: before.stdout != after.stdout
# scoop's exit code is lost through Out-String, so a failed update would otherwise
# look like success. If an update was attempted, the version must have changed.
failed_when: >-
after.rc != 0 or
(upd is not skipped and before.stdout | trim == after.stdout | trim)
- name: Report
ansible.builtin.debug:
msg: "{{ before.stdout | trim }} -> {{ after.stdout | trim }}"
+73
View File
@@ -0,0 +1,73 @@
---
# Install Windows Updates on the [windows] inventory group and reboot if required.
# Usage:
# ansible-playbook windows/update.yaml # install + reboot if needed
# ansible-playbook windows/update.yaml -e reboot=false # install only, report if reboot pending
# ansible-playbook windows/update.yaml -e search_only=true # just list available updates
- name: Update Windows servers
hosts: windows
gather_facts: false
vars:
reboot: true
search_only: false
update_categories:
- SecurityUpdates
- CriticalUpdates
- UpdateRollups
- DefinitionUpdates
- Updates
tasks:
- name: Check connectivity
ansible.windows.win_ping:
- name: Search for available updates
ansible.windows.win_updates:
category_names: "{{ update_categories }}"
state: searched
register: search
when: search_only | bool
- name: List available updates
ansible.builtin.debug:
msg: "{{ search.updates | dict2items | map(attribute='value.title') | list }}"
when: search_only | bool
- name: Install updates and report
when: not search_only | bool
block:
- name: Install updates
ansible.windows.win_updates:
category_names: "{{ update_categories }}"
state: installed
reboot: "{{ reboot | bool }}"
reboot_timeout: 3600
register: result
# With reboot=false, updates blocked by the pending restart (WU_E_INSTALL_NOT_ALLOWED)
# are expected; only fail on other errors.
failed_when: >-
result.failed_update_count | default(0) | int > 0 and
(reboot | bool or
result.updates | dict2items | map(attribute='value')
| selectattr('failure_hresult_code', 'defined')
| rejectattr('failure_hresult_code', 'equalto', 2149842966) | list | length > 0)
# Runs even if the install failed, so a failed run still shows what is pending.
always:
# Re-search afterwards: win_updates marks updates that were staged for a reboot as
# "not installed" even after the reboot applies them, so this is the reliable view.
- name: Check what is still pending
ansible.windows.win_updates:
category_names: "{{ update_categories }}"
state: searched
register: after
- name: Report
vars:
reboot_pending: "{{ after.reboot_required | default(result.reboot_required | default(false)) | bool }}"
ansible.builtin.debug:
msg:
- "Processed this run: {{ result.updates | default({}) | dict2items | map(attribute='value.title') | list }}"
- "Still pending: {{ after.updates | default({}) | dict2items | map(attribute='value.title') | list }}"
- "Reboot still required: {{ reboot_pending }}{{ ' - reboot and re-run to finish' if reboot_pending | bool else '' }}"