mirror of
https://github.com/RWejlgaard/pez-infra.git
synced 2026-05-06 04:14:43 +00:00
46 lines
1.3 KiB
YAML
46 lines
1.3 KiB
YAML
---
|
|
# Update Linux hosts only (apt + Alpine apk).
|
|
# Usage: ansible-playbook playbooks/update-linux.yml
|
|
#
|
|
# Equivalent to: ansible-playbook playbooks/update-all.yml --tags linux,alpine
|
|
# This is a convenience wrapper for when you only want Linux hosts.
|
|
|
|
- name: Update Linux hosts (apt)
|
|
hosts: linux
|
|
ignore_unreachable: true
|
|
tasks:
|
|
- name: Apt update + upgrade + autoremove
|
|
ansible.builtin.apt:
|
|
update_cache: true
|
|
upgrade: dist
|
|
autoremove: true
|
|
autoclean: true
|
|
register: apt_result
|
|
|
|
- name: Show upgrade summary
|
|
ansible.builtin.debug:
|
|
msg: "{{ apt_result.stdout_lines | default(['No output']) }}"
|
|
|
|
- name: Check if reboot is required
|
|
ansible.builtin.stat:
|
|
path: /var/run/reboot-required
|
|
register: reboot_required
|
|
|
|
- name: Notify if reboot needed
|
|
ansible.builtin.debug:
|
|
msg: "WARNING: REBOOT REQUIRED on {{ inventory_hostname }}"
|
|
when: reboot_required.stat.exists
|
|
|
|
- name: Update Alpine hosts (apk)
|
|
hosts: alpine
|
|
ignore_unreachable: true
|
|
tasks:
|
|
- name: Apk update + upgrade
|
|
community.general.apk:
|
|
update_cache: true
|
|
upgrade: true
|
|
register: apk_result
|
|
|
|
- name: Show upgrade summary
|
|
ansible.builtin.debug:
|
|
msg: "{{ apk_result.stdout_lines | default(['No output']) }}"
|