From fe3119cfafbc012bcafbf6b755bc7412532b4b0d Mon Sep 17 00:00:00 2001 From: Justin Date: Thu, 12 Nov 2026 19:35:29 -0600 Subject: [PATCH] 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 --- ansible.cfg | 1 + ubuntu/update-beszel.yaml | 64 +++++++++++++++++++++++++++++++++++++++ windows/update.yaml | 53 ++++++++++++++++++++++++++++++++ 3 files changed, 118 insertions(+) create mode 100644 ubuntu/update-beszel.yaml create mode 100644 windows/update.yaml diff --git a/ansible.cfg b/ansible.cfg index 98a364c..cd0e1bc 100644 --- a/ansible.cfg +++ b/ansible.cfg @@ -1,4 +1,5 @@ [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). # These warnings can be silenced by adjusting this setting to False. ;action_warnings=True diff --git a/ubuntu/update-beszel.yaml b/ubuntu/update-beszel.yaml new file mode 100644 index 0000000..a7b0015 --- /dev/null +++ b/ubuntu/update-beszel.yaml @@ -0,0 +1,64 @@ +--- +# 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 + + - name: Report + ansible.builtin.debug: + msg: "{{ before.stdout }} -> {{ after.stdout }}" diff --git a/windows/update.yaml b/windows/update.yaml new file mode 100644 index 0000000..4498b38 --- /dev/null +++ b/windows/update.yaml @@ -0,0 +1,53 @@ +--- +# 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 + ansible.windows.win_updates: + category_names: "{{ update_categories }}" + state: installed + reboot: "{{ reboot | bool }}" + reboot_timeout: 3600 + register: result + when: not search_only | bool + + - name: Report + ansible.builtin.debug: + msg: + - "Installed: {{ result.installed_update_count }}" + - "Failed: {{ result.failed_update_count | default(0) }}" + - "Reboot still required: {{ result.reboot_required }}" + - "{{ result.updates | dict2items | map(attribute='value.title') | list }}" + when: not search_only | bool