--- # lifted from here # https://gist.github.com/yorickdowne/3cecc7b424ce241b173510e36754af47 - name: Trixie Upgrade Pipeline hosts: all become: yes tasks: - name: Get distribution version setup: filter: ansible_distribution* - name: Skip if not Debian 12 meta: end_host when: ansible_distribution != 'Debian' or ansible_distribution_major_version != '12' - name: apt clean apt: clean: yes - name: Get filesystem facts setup: filter: ansible_mounts - name: Fail if free space on / is below 5 GiB ansible.builtin.assert: that: - item.size_available > (5 * 1024 * 1024 * 1024) fail_msg: "Free disk space on {{ item.mount }} is below 5 GiB" loop: "{{ ansible_mounts }}" when: item.mount == "/" - name: Perform apt upgrade apt: upgrade: dist update_cache: yes - name: Perform apt autoremove apt: autoremove: yes - name: Perform apt clean apt: clean: yes - name: Check if reboot required ansible.builtin.stat: path: /run/reboot-required get_checksum: no register: reboot_required_file - name: Reboot if required ansible.builtin.reboot: msg: "Reboot initiated by Ansible" connect_timeout: 5 reboot_timeout: 600 pre_reboot_delay: 0 post_reboot_delay: 60 test_command: whoami when: reboot_required_file.stat.exists - name: Update OS in sources.list ansible.builtin.replace: path: /etc/apt/sources.list regexp: 'bookworm' replace: 'trixie' - name: Find all 3rd-party repos ansible.builtin.find: paths: /etc/apt/sources.list.d patterns: '*' recurse: no register: third_party_repos - name: Switch 3rd-party repos from bookworm to trixie ansible.builtin.replace: path: "{{ item.path }}" regexp: 'bookworm' replace: 'trixie' loop: "{{ third_party_repos.files }}" loop_control: label: "{{ item.path }}" - name: Perform apt upgrade, moving to Trixie apt: upgrade: dist update_cache: yes - name: Get distribution version setup: filter: ansible_distribution* - name: Fail if not Debian 13 assert: that: - ansible_distribution_major_version == '13' fail_msg: "Upgrade to Debian 13 failed" - name: Perform apt autoremove apt: autoremove: yes - name: Perform apt clean apt: clean: yes - name: Reboot to trixie ansible.builtin.reboot: msg: "Reboot initiated by Ansible" connect_timeout: 5 reboot_timeout: 600 pre_reboot_delay: 0 post_reboot_delay: 60 test_command: whoami - name: Modernize apt sources ansible.builtin.command: cmd: apt -y modernize-sources ...