# Installing Ubuntu phased updates using ansible.builtin.apt?

**URL:** <https://forum.ansible.com/t/installing-ubuntu-phased-updates-using-ansible-builtin-apt/46640>\
**Category:** Get Help\
**Tags:** apt, ubuntu\
**Created:** [November 11, 2026, 9:51am UTC](https://forum.ansible.com/t/installing-ubuntu-phased-updates-using-ansible-builtin-apt/46640 "2026-11-11T09:51:27Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![chris](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/chris/32/293_2.png) [@chris](https://forum.ansible.com/u/chris)\
**Post date:** [November 11, 2026, 9:51am UTC](https://forum.ansible.com/t/installing-ubuntu-phased-updates-using-ansible-builtin-apt/46640/1 "2026-11-11T09:51:27Z")

</div>

Ubuntu [phased updates](https://ubuntu.com/server/docs/explanation/software/about-apt-upgrade-and-phased-updates/) don’t appear to be installable using `ansible.builtin.apt` even with [allow\_change\_held\_packages](https://docs.ansible.com/projects/ansible/latest/collections/ansible/builtin/apt_module.html#parameter-allow_change_held_packages) set to `True`?

This is how I’m working around this:

```yaml
- name: Check for phased updates # noqa: command-instead-of-module
  ansible.builtin.command:
    cmd: apt-get -sq --allow-change-held-packages full-upgrade
  environment:
    DEBIAN_FRONTEND: noninteractive
  check_mode: false
  changed_when: false
  register: update_simulate_full_upgrade

- name: Ubuntu phased updates
  block:

    - name: Set a fact for available phased updates
      ansible.builtin.set_fact:
        update_phased_updates_available: >-
          {{ update_simulate_full_upgrade.stdout_lines
          | ansible.builtin.select('ansible.builtin.regex', '^[][][a-z0-9]'
          | ansible.builtin.map('ansible.builtin.regex_replace', '^[][]')
          | ansible.builtin.join(' ')
          | ansible.builtin.split(' ') }}

    - name: Debug update_phased_updates_available
      ansible.builtin.debug:
        var: update_phased_updates_available
      when:
        - update_phased_updates_available is ansible.builtin.defined
        - update_phased_updates_available | ansible.builtin.type_debug == "list"
        - update_phased_updates_available != []

    # The ansible.builtin.apt module can't be used to install phased updates
    - name: Install phased updates # noqa: command-instead-of-module
      ansible.builtin.command:
        cmd: >-
          apt-get install -yqq -o "Dpkg::Options::=--force-confdef" -o "Dpkg::Options::=--force-confold"
          --allow-change-held-packages {{ '--simulate' if ansible_check_mode | ansible.builtin.bool }}
          {{ update_phased_updates_available | ansible.builtin.join(' ') }}
      environment:
        DEBIAN_FRONTEND: noninteractive
      check_mode: false
      register: update_phased_updates_installed
      when:
        - update_phased_updates | ansible.builtin.bool
        - update_phased_updates_available is ansible.builtin.defined
        - update_phased_updates_available | ansible.builtin.type_debug == "list"
        - update_phased_updates_available != []

    - name: Debug update_phased_updates_installed.stdout_lines
      ansible.builtin.debug:
        var: update_phased_updates_installed.stdout_lines
        verbosity: >-
          {{ '0' if (ansible_check_mode | ansible.builtin.bool) or (ansible_diff_mode | ansible.builtin.bool) else '1' }}
      tags:
        - debug

  when:
    - update_simulate_full_upgrade.stdout_lines | ansible.builtin.select('ansible.builtin.regex', '^[][][a-z0-9]') != []

```

Would / could / should a `upgrade_phased_packages` option be considered as an appropriate addition?
