Update playbooks/update.yaml
This commit is contained in:
+36
-3
@@ -1,24 +1,51 @@
|
||||
---
|
||||
- name: APT update/upgrade zonder reboot
|
||||
hosts: all
|
||||
become: true
|
||||
gather_facts: true
|
||||
|
||||
environment:
|
||||
DEBIAN_FRONTEND: noninteractive
|
||||
APT_LISTCHANGES_FRONTEND: none
|
||||
NEEDRESTART_MODE: a
|
||||
|
||||
tasks:
|
||||
- name: Update APT package cache
|
||||
ansible.builtin.apt:
|
||||
update_cache: true
|
||||
cache_valid_time: 3600
|
||||
lock_timeout: 300
|
||||
register: apt_update_result
|
||||
|
||||
- name: Upgrade installed packages
|
||||
ansible.builtin.apt:
|
||||
upgrade: dist
|
||||
autoremove: true
|
||||
autoclean: true
|
||||
dpkg_options: "force-confdef,force-confold"
|
||||
lock_timeout: 300
|
||||
register: apt_upgrade_result
|
||||
|
||||
- name: Reset SSH connection after package upgrade
|
||||
ansible.builtin.meta: reset_connection
|
||||
|
||||
- name: Wait until host is reachable again
|
||||
ansible.builtin.wait_for_connection:
|
||||
connect_timeout: 10
|
||||
sleep: 2
|
||||
timeout: 120
|
||||
|
||||
- name: Remove unused packages
|
||||
ansible.builtin.apt:
|
||||
autoremove: true
|
||||
purge: false
|
||||
lock_timeout: 300
|
||||
register: apt_autoremove_result
|
||||
|
||||
- name: Clean obsolete package files
|
||||
ansible.builtin.apt:
|
||||
autoclean: true
|
||||
lock_timeout: 300
|
||||
register: apt_autoclean_result
|
||||
|
||||
- name: Check if reboot is required
|
||||
ansible.builtin.stat:
|
||||
path: /var/run/reboot-required
|
||||
@@ -39,7 +66,13 @@
|
||||
ansible.builtin.set_fact:
|
||||
apt_report:
|
||||
host: "{{ inventory_hostname }}"
|
||||
changed: "{{ apt_update_result.changed or apt_upgrade_result.changed }}"
|
||||
changed: >-
|
||||
{{
|
||||
apt_update_result.changed
|
||||
or apt_upgrade_result.changed
|
||||
or apt_autoremove_result.changed
|
||||
or apt_autoclean_result.changed
|
||||
}}
|
||||
reboot_required: "{{ reboot_required.stat.exists }}"
|
||||
reboot_required_packages: >-
|
||||
{{
|
||||
|
||||
Reference in New Issue
Block a user