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

apt::pin ignores order parameter #1093

Open
alext opened this issue Mar 21, 2023 · 3 comments
Open

apt::pin ignores order parameter #1093

alext opened this issue Mar 21, 2023 · 3 comments

Comments

@alext
Copy link

alext commented Mar 21, 2023

Describe the Bug

The order parameter to the apt::pin resource is ignored and has no effect.

Expected Behavior

Given the following:

apt::pin { 'alpha':
  packages => 'something',
  priority => 300,
  order => 20,
}
apt::pin { 'bravo':
  packages => 'something',
  version => '1.2.3',
  priority => 600,
  order => 10,
}

I'd expect the files 10bravo.pref and 20alpha.pref to be created in /etc/apt/preferences.d so that bravo takes priority over alpha when read by apt..

Steps to Reproduce

Given code like the above, observe that the order property is ignored, and the created files are called alpha.pref and bravo.pref.

Environment

  • Version 9.0.2
  • Platform Ubuntu 22.04

Additional Context

I think this stems from these lines in setting.pp that ignores the priority value for "list" and "pref" type settings.

@jps-help
Copy link

I've just noticed the same issue as well. Seems like an easy enough fix, however it will likely be a breaking change since it would update all existing .prefs files with a new prefix.

I will see if I can draft a PR

@jps-help
Copy link

jps-help commented Jun 3, 2024

I've been looking into this but not sure what the best practice is for naming of APT preferences.

Documentation explicitly states

File naming in /etc/apt/preferences. d/ is free but the last in alphabetical order takes precedence.

So the ordering of files makes sense to ensure preferences are evaluated correctly. However, the numbered prefex is not mandatory and I know of at least one example where a vendor (Ubuntu) is not using them.

$ ls -l /etc/apt/preferences.d/ubuntu-pro-esm-*
-rw-r--r-- 1 root root 437 Apr  2 14:13 /etc/apt/preferences.d/ubuntu-pro-esm-apps
-rw-r--r-- 1 root root 429 Apr  2 14:13 /etc/apt/preferences.d/ubuntu-pro-esm-infra

If we force the use of the order/priority parameter and prefix all managed .prefs files, we would essentially make all managed resources lower priority to vendor configs which don't follow that naming scheme.

In this case, it might be best if we leave the apt::pin type as-is and just use the resource title to create the needed priorities.
e.g. manually naming the resource 99-my-pref

@jps-help
Copy link

jps-help commented Jun 3, 2024

If this is agreed as the best option, we could do a bit of cleanup on the apt::pin defined type since the order param isn't really needed and a default is supplied by apt::setting anyway.

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

No branches or pull requests

3 participants