Skip to content
Snippets Groups Projects

Reboot hosts after changed sources list and dist-upgrade when system is...

Merged Michael Thaler requested to merge main into stable
2 files
+ 63
9
Compare changes
  • Side-by-side
  • Inline
Files
2
+ 53
9
---
#### CLEANUP
#### SOURCES
- name: Set current debian stable sources list at /etc/apt/sources.list
copy:
ansible.builtin.copy:
dest: /etc/apt/sources.list
owner: root
group: root
@@ -11,18 +15,57 @@
deb http://ftp.at.debian.org/debian/ bullseye-backports main contrib non-free
register: stable_sources_list
- name: Update the packagecache and perform a safe upgrade on non-changed sources list
when: ( stable_sources_list is succeeded ) and ( not stable_sources_list.changed )
apt:
- name: Set current debian stable preferences list
ansible.builtin.copy:
dest: /etc/apt/preferences
owner: root
group: root
mode: u=rw,o=rx,g=r
content: |
Package: *
Pin: release n=bullseye
Pin-Priority: 991
Package: *
Pin: release n=bullseye-updates
Pin-Priority: 992
Package: *
Pin: release n=bullseye-backports
Pin-Priority: 990
#### INSTALL, UPGRADE
- name: Update the packagecache and perform a safe upgrade on non-changed sources list for Ansible version < 2.12
when: ( ansible_version.full < "2.12" ) and ( stable_sources_list is succeeded ) and ( not stable_sources_list.changed )
ansible.builtin.apt:
update_cache: yes
upgrade: yes
autoremove: yes
autoclean: yes
force: yes
- name: Update the packagecache and perform a safe upgrade on non-changed sources list for Ansible version >= 2.12
when: ( ansible_version.full >= "2.12" ) and ( stable_sources_list is succeeded ) and ( not stable_sources_list.changed )
ansible.builtin.apt:
update_cache: yes
upgrade: yes
autoremove: yes
autoclean: yes
allow_downgrade: yes
- name: Update the packagecache and perform a dist upgrade on changed sources list
when: stable_sources_list.changed
apt:
- name: Update the packagecache and perform a dist upgrade on changed sources list for Ansible version < 2.12
when: (stable_sources_list.changed) and (ansible_version.full < "2.12")
ansible.builtin.apt:
update_cache: yes
upgrade: dist
autoremove: yes
autoclean: yes
force: yes
register: dist_upgrade
- name: Update the packagecache and perform a dist upgrade on changed sources list for Ansible version >= 2.12
when: (stable_sources_list.changed) and (ansible_version.full >= "2.12")
ansible.builtin.apt:
update_cache: yes
upgrade: dist
autoremove: yes
@@ -30,8 +73,9 @@
allow_downgrade: yes
register: dist_upgrade
- name: Reboot hosts after changed sources list and dist-upgrade
when: ( stable_sources_list.changed ) and ( dist_upgrade.changed )
- name: Reboot hosts after changed sources list and dist-upgrade when system is systemd-booted ( e.g. not running in a podman container )
when: ( ansible_service_mgr == 'systemd' ) and ( stable_sources_list.changed ) and ( dist_upgrade.changed )
ansible.builtin.reboot:
reboot_timeout: 1200
#### INIT
Loading