Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fails to downgrade packages when Ansible is installed from PPA #340

Open
jacobgkau opened this issue Nov 7, 2024 · 9 comments · May be fixed by #341
Open

Fails to downgrade packages when Ansible is installed from PPA #340

jacobgkau opened this issue Nov 7, 2024 · 9 comments · May be fixed by #341

Comments

@jacobgkau
Copy link
Member

As reported by @hawko2600 at #330 (comment):

Nov 5 22:21:18 pop-os pop-upgrade[35075]: The following packages have unmet dependencies:
Nov 5 22:21:18 pop-os pop-upgrade[35075]: ansible-core : Breaks: ansible (< 4.6.0-1~) but 2.10.7+merged+base+2.10.8+
dfsg-1 is to be installed
Nov 5 22:21:18 pop-os pop-upgrade[35075]: Recommends: ansible (>= 4.6.0-1~) but 2.10.7+merged+base+2.
10.8+dfsg-1 is to be installed
Nov 5 22:21:18 pop-os pop-upgrade[35075]: E: Unable to correct problems, you have held broken packages.
Nov 5 22:21:18 pop-os pop-upgrade[28948]: [https://github.com/pop-os/upgrade/pull/33[1mINFO https://github.com/pop-os/upgrade/pull/33[0m] daemon/mod.rs#033[0m#033[1m:https://github.com/pop-os/upgrade/pull/33[0m#033[1;35m362#033[0m: upgrade result: Err(Downgrade(apt-get downgrade
Nov 5 22:21:18 pop-os pop-upgrade[28948]: Caused by:
Nov 5 22:21:18 pop-os pop-upgrade[28948]: status is unknown: exit status: 100))
Nov 5 22:21:18 pop-os pop-upgrade[35078]: Canceled hold on pop-upgrade.

I'm able to recreate this from a fresh VM installation by adding the Ansible PPA and installing ansible before attempting the upgrade.

@jacobgkau
Copy link
Member Author

This is the command pop-upgrade is generating to do the downgrade:

sudo apt install ansible-core=2.12.0-1 ansible=2.10.7+merged+base+2.10.8+dfsg-1

Testing running that manually after the failure, apt offers to proceed if I specify ansible-core=2.12.0-1 or ansible=2.10.7+merged+base+2.10.8+dfsg-1, but not if I specify both. When I specify only ansible=2.10.7+merged+base+2.10.8+dfsg-1, apt offers to remove ansible-core. When I specify only ansible-core=2.12.0-1, apt offers a transaction that doesn't touch the ansible package.

@jacobgkau
Copy link
Member Author

Looking at https://packages.ubuntu.com/jammy/ansible-core, Ubuntu's ansible-core package recommends ansible (>= 4.6.0-1~), even though Ubuntu's ansible package for Jammy is 2.10.7+merged+base+2.10.8+dfsg-1. Not sure why that is.

@jacobgkau
Copy link
Member Author

On a fresh system without the Ansible PPA, attempting to install ansible and ansible-core at the same time from Ubuntu's repo fails with a similar error message. On the surface, this seems like broken Ubuntu packaging. https://docs.ansible.com/ansible/latest/installation_guide/installation_distros.html suggests ansible-core should provide a minimal subset of the full functionality that ansible provides. Since Ubuntu's ansible package doesn't depend on ansible-core at all, I have to assume (if they don't just have it packaged wrong) that Ubuntu didn't intend for both ansible and ansible-core to be installed at the same time.

@jacobgkau
Copy link
Member Author

jacobgkau commented Nov 7, 2024

Without any additional PPAs, installing ansible if ansible-core's installed simply removes ansible-core. Given that the former is the more capable package, I think just removing ansible-core if ansible is to be downgraded (similar to the workaround we just did for the Papirus packages) would be a reasonable fix for the issue. ansible should do everything ansible-core can do, and the user can still install -core from the PPA again after the upgrade's complete if they want it for some reason (I guess the PPA installs -core as a dependency of the main package, so it will just get installed again if/when the user re-adds the PPA).

@jacobgkau
Copy link
Member Author

jacobgkau commented Nov 7, 2024

Looking at Ubuntu's Ansible packages for Noble, it doesn't look like this package conflict would be occur on that version, as ansible-core recommends Ansible > 7.x and they package Ansible 9.x.

@jacobgkau
Copy link
Member Author

The logic for this can't be quite as simple as it was for the Papirus issue, because ansible-core is getting put into the downgrade list before ansible.

Ideally, we want to remove ansible-core only if ansible is installed/on the downgrade list. But we need to make sure ansible-core isn't added to the downgrade list anyway before it's removed, because otherwise the apt-get install command will just try to put it back (and hit the same dependency error).

@jacobgkau
Copy link
Member Author

We could alternatively just make sure ansible-core=... is not part of the downgrade command if ansible=... is part of it, and apt should sort itself out by removing ansible-core=... (since we wouldn't be explicitly requesting it to be installed within the same command). But it looks like there's no way to remove an argument from a Tokio command struct once it's been pushed.

@jacobgkau
Copy link
Member Author

jacobgkau commented Nov 8, 2024

Alright, ansible-core and ansbile have conflicting files (e.g. the Ansible binary). Simply downgrading ansible and trying to let apt automatically remove ansible-core doesn't work because they're not marked as conflicting, and the ansible-core version from the PPA doesn't have the "breaks" line that Ubuntu's does only "breaks" ansible < 2.10.x when Ubuntu ships 2.10.7. So we'll have to explicitly remove ansible-core in this case, not just prevent it from being in the downgrade command.

It will still need to be coded slightly differently from the Papirus exception because we still need to prevent ansible-core from being added to the downgrade command (otherwise apt will still try to install incompatible versions of ansible and ansible-core at the same time once it's done building that command).

@hawko2600
Copy link

Without any additional PPAs, installing ansible if ansible-core's installed simply removes ansible-core. Given that the former is the more capable package, I think just removing ansible-core if ansible is to be downgraded (similar to the workaround we just did for the Papirus packages) would be a reasonable fix for the issue. ansible should do everything ansible-core can do, and the user can still install -core from the PPA again after the upgrade's complete if they want it for some reason (I guess the PPA installs -core as a dependency of the main package, so it will just get installed again if/when the user re-adds the PPA).

It was a good guess.
% nala show ansible
Package: ansible
Version: 10.5.0-1ppa~jammy
Architecture: all
Installed: yes
Priority: optional
Essential: no
Section: admin
Source: ansible
Maintainer: Ansible Community Builds ansible-community-builds@redhat.com
Installed-Size: 197.3 MB
Depends: ansible-core, python3:any
Recommends: python3-jmespath, python3-winrm
Homepage: https://ansible.com/
APT-Sources: local install
Description: Ansible collections for ansible-core
Batteries-included package providing a curated set of Ansible collections

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants