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]>
This commit is contained in:
1 parent
2b2a56dbca
commit
fe3119cfaf
3 files changed
+118
No files matched your search
@@ -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
|
||||
|
||||
@@ -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 }}"
|
||||
@@ -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
|
||||
Reference in new issue
Block a user