Can no longer use apt patterns in apt packages
Bug report
Since the apt package handling now checks to see that packages exist in the package list before trying to install (https://github.com/canonical/cloud-init/blob/main/cloudinit/distros/package_management/apt.py#L129), it is no longer possible to specify apt patterns to install, e.g. ?priority(standard). If this is fixed, it should support complex apt patterns, e.g. '?priority(standard) ?not(?name(systemd-timesyncd))'.
Steps to reproduce the problem
#cloud-config
packages: ['?priority(standard)']
Environment details
- Cloud-init version: 25.1.4
- Operating System Distribution: Debian 13
- Cloud provider, platform or installer type: LXD/Incus
cloud-init logs
apt.py[DEBUG]: The following packages were not found by APT so APT will not attempt to install them: ['?priority(standard)']
This behavior changed in 23.4. Trying to fall back to snap changed the behavior because it now attempts to check if the package exists before installing the package.
There was some discussion in https://github.com/canonical/cloud-init/pull/5426 [1] about redesigning the UI to avoid issues like this, but progress on that has not transpired.
[1] which addressed a similar issue caused by the same behavior change