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

CFE-4450: Allow passing environment variables to package managers #2963

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

amousset
Copy link
Contributor

Allow passing options to the package managers modules through env:NAME=VERSION options.

Taking the easiest path. If it is considered acceptable I'll add a test case and documentation.

@amousset amousset marked this pull request as draft November 22, 2024 10:08
@nickanderson
Copy link
Member

Do you have some explicit examples of the use case for each of the package managers as well?

@amousset
Copy link
Contributor Author

amousset commented Dec 9, 2024

For APT, for example controling needrestart's behavior.

But the main use case is for non-standard packages that allow customizing the configuration through env vars used in the postinst script. GitLab is one of them (https://docs.gitlab.com/omnibus/installation/index.html#set-up-the-initial-account):

sudo GITLAB_ROOT_EMAIL="<[email protected]>" GITLAB_ROOT_PASSWORD="<strongpassword>" EXTERNAL_URL="http://gitlab.example.com" apt install gitlab-ee

@nickanderson
Copy link
Member

From my side I think it makes sense, I will invite @olehermanse @craigcomstock to bike shed a bit.

Copy link
Contributor

@craigcomstock craigcomstock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems fine to me. Seeing this change here kind of begs to have a common python script to share such repeated code.

Also, it's a shame to not have the same for non-python modules if they even need it. For example, apk for alpine, but I have never needed to use env vars so probably fine. We can leave the complex usage to the complex systems: apt, yum and zypper. ;)

Definitely was looking for documentation and examples (a test case is usually a great example) before I read your description. So with those two pieces this looks good to me!

Thanks for the contribution!

@amousset
Copy link
Contributor Author

I created some basic documentation in cfengine/documentation#3374. I also took a look at the tests but it seems there are no tests covering the options attribute, and that there is no testing mechanism for "real module/fake package manager" that would be convenient here (there is "fake module/no PM" and "real module/real PM"). I'll try to take a closer look.

@amousset amousset force-pushed the env-var-package-modules branch from 1e58dfd to 31b014d Compare January 9, 2025 16:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants