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

FreeBSD pkg provider battch support. #29707

Closed

Conversation

abednarik
Copy link
Contributor

When installing packages in FreeBSD that have an interactive post-installation BATCH
environment variable is used to answer all post install questions. The idea here is
to check if that variable is set and in case is True make sure to use it

Fixes #27056

I'm sending this against develop because is more or less WIP or a feature for now. I will take of doing a proper PR in case this code is good enough and do what it says.

When installing packages in FreeBSD thatt have an interactive post-installation BATCH
environment variable is used to answer all post install questions. The idea here is
to check if that variable is set and in case is True make sure to use it
@cachedout
Copy link
Contributor

I'm not sure I follow this. In what case is a value present in the environment but then needs to be re-set to that same vaule?

@cachedout cachedout added the Pending-Discussion The issue or pull request needs more discussion before it can be closed or merged label Dec 15, 2015
@abednarik
Copy link
Contributor Author

HI @cachedout I was assuming that salt in not getting BATCH=yes from environment based on this issue #27056

Thinking this again, I don't see any reason why BATCH=yes is not set inside Salt since running a state that requires manual interaction doesn't sound a good idea.
What do you think about setting this by default to yes? Other option could be to give the user the chance to set batch: false, but I don't see a reason why someone could do that.

Ping @oogali the original reported.

@jfindlay
Copy link
Contributor

@abednarik, cmd.run* allow for an environment var to be set locally for a single command run,

__salt__['cmd.run']('pkg install htop', env={'BATCH': 'yes'})

@abednarik
Copy link
Contributor Author

Hi @jfindlay thanks for that. I'm still thinking why BATCH=yes is not set by default, since otherwise installing packages with post install script will not work.
I'm here just to collaborate. I will wait for better decisions on how to move forward with this.

Cheers.

@jfindlay
Copy link
Contributor

@abednarik, no problem. Your help is very much appreciated.

@abednarik
Copy link
Contributor Author

Update: https://www.freebsd.org/cgi/man.cgi?query=pkg_add&manpath=FreeBSD+7.2-RELEASE

pkg_add in FreeBSD doesn't support non interactive mode.

@abednarik
Copy link
Contributor Author

HI @jfindlay / @cachedout

This looks weird for me {this env is not defined in this function and is referenced as a local variable ( function scope ). Maybe that's the reason why env variables are not used when cmd.run is executed?

@jfindlay
Copy link
Contributor

@abednarik, that would definitely be a problem. :)

@abednarik
Copy link
Contributor Author

Thanks. Will check how salt parsers and call that module to see if I can get that variable inside that function.

@ohauer
Copy link

ohauer commented Dec 20, 2015

Maybe I can bring some light into this.
@abednarik Do you mean the old deprected pkg_tools or pkg ?
The provided link to the FreeBSD man page goes to the deprecated pkg_tools (pkg_add, pkg_delete, pkg_info and so on)
New FreeBSD releases containing a boot strapper installing pkg ( https://github.com/freebsd/pkg/ )

Regarding the env BATCH, this is supported by the old (pkg_...) tools and by pkg.
The env is not used by the pkg tool but passed to the pkg-install script, for example see the postfix pkg-install script that uses the env BATCH=yes
https://svnweb.freebsd.org/ports/head/mail/postfix/files/pkg-install.in?revision=385965&view=markup

@abednarik
Copy link
Contributor Author

HI @ohauer

Thanks for bring some light here :) After reading your comment and the original issue, i found a mistake from my side. The issue was reported against pgkng and I was trying to fix this issue in pkd_add..

I will close this one, since nobody reports an issue with this old version.

Thanks.

@abednarik abednarik closed this Dec 21, 2015
@abednarik abednarik deleted the freebsd_pgk_support_batch_mode branch December 21, 2015 01:32
@abednarik
Copy link
Contributor Author

After digging a bit around this I found out

  • In pkgng BATCH=yes looks like is was replaced with ASSUME_ALWAYS_YES=YES
  • Similar to apt-get now you can pass this as an argument with -y See this and this

One last thing looking at pkgng.py is that the argument -y is anly use when dryrun is set to True. See here
I think -y should be always present, same as -q for quiet output.

@abednarik
Copy link
Contributor Author

Hope this one #29909 fixes this issue.

@ohauer
Copy link

ohauer commented Dec 21, 2015

I don't think the general usage of '-y' will fix the issue from #27056 as pkgng does not generate the required BATCH=yes env.

I identified four ports using the env BATCH in the install or de-install script since they have to modify files in the base OS (e.g. /etc instead /usr/local/etc or /etc/services) to change base OS settings.
In case of postfix a wrapper script will be changed so the postfix binaries are used instead of sendmail (similar to alternative on RHEL).
But this would happen only the first time postfix is installed not during updates.
I'm not a salt expert (just start using it) but the maintainer of the FreeBSD postfix ports and if we can find a better solution for salt I'm happy to implement that in the postfix ports (e.g. check for an env var set by salt during all operations and so assuming BATCH=yes)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Pending-Discussion The issue or pull request needs more discussion before it can be closed or merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants