salt: pkgng provider on FreeBSD does not do BATCH=yes

The pkgng provider on FreeBSD does not use the “BATCH=yes” environment setting when installing new packages.

This is problematic when installing packages that have an interactive post-install script (e.g. mail/postfix). The lack of the batch flag causes pkg to forever wait for a user response (which it will never receive), which in turn causes the minion to “hang”.

# pkg install -qy postfix
===> Creating users and/or groups.
Using existing group 'mail'.
Creating group 'maildrop' with gid '126'.
Creating group 'postfix' with gid '125'.
Creating user 'postfix' with uid '125'.
Adding user 'postfix' to group 'mail'.
Would you like to activate Postfix in /etc/mail/mailer.conf [n]? ^C

But, because the minion is still reachable by the master, your highstate never completes or times out, and you then have to log in, kill the minion child, manually install the package in question, and then restart your highstate run.

# salt --versions-report
           Salt: 2015.5.2
         Python: 2.7.9 (default, Aug 27 2015, 01:28:02)
         Jinja2: 2.7.3
       M2Crypto: 0.22
 msgpack-python: 0.4.2
   msgpack-pure: Not Installed
       pycrypto: 2.6.1
        libnacl: Not Installed
         PyYAML: 3.11
          ioflo: Not Installed
          PyZMQ: 14.6.0
           RAET: Not Installed
            ZMQ: 4.1.3
           Mako: Not Installed

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Comments: 16 (10 by maintainers)

Most upvoted comments

I have this exact problem when installing postfix using the postfix-formula.

First I tested using env vars and shell, with these results (using bash):

[root@salt]# export ASSUME_ALWAYS_YES=YES
[root@salt]# pkg install -y postfix
Updating FreeBSD repository catalogue...
FreeBSD repository is up to date.
Updating Perceptyx repository catalogue...
Perceptyx repository is up to date.
All repositories are up to date.
Checking integrity... done (0 conflicting)
The following 1 package(s) will be affected (of 0 checked):

New packages to be INSTALLED:
	postfix: 3.3.1_1,1 [FreeBSD]

Number of packages to be installed: 1

The process will require 7 MiB more space.
[1/1] Installing postfix-3.3.1_1,1...
===> Creating groups.
Using existing group 'mail'.
Using existing group 'maildrop'.
Using existing group 'postfix'.
===> Creating users
Using existing user 'postfix'.
[1/1] Extracting postfix-3.3.1_1,1: 100%
Would you like to activate Postfix in /usr/local/etc/mail/mailer.conf [n]?

So it keeps waiting there for interaction, even when explicitly adding ASSUME_ALWAYS_YES=YES.

Next step is using BATCH=true:

[root@salt]# export BATCH=true
[root@salt]# pkg install postfix
Updating FreeBSD repository catalogue...
FreeBSD repository is up to date.
Updating Perceptyx repository catalogue...
Perceptyx repository is up to date.
All repositories are up to date.
Checking integrity... done (0 conflicting)
The following 1 package(s) will be affected (of 0 checked):

New packages to be INSTALLED:
	postfix: 3.3.1_1,1 [FreeBSD]

Number of packages to be installed: 1

The process will require 7 MiB more space.
[1/1] Installing postfix-3.3.1_1,1...
===> Creating groups.
Using existing group 'mail'.
Using existing group 'maildrop'.
Using existing group 'postfix'.
===> Creating users
Using existing user 'postfix'.
[1/1] Extracting postfix-3.3.1_1,1: 100%

===============================================================
Postfix was *not* activated in /usr/local/etc/mail/mailer.conf! 

To finish installation run the following commands:

  mkdir -p /usr/local/etc/mail
  install -m 0644 /usr/local/share/postfix/mailer.conf.postfix /usr/local/etc/mail/mailer.conf
===============================================================

Message from postfix-3.3.1_1,1:

To use postfix instead of sendmail:
  - clear sendmail queue and stop the sendmail daemons

Run the following commands to enable postfix during startup:
  - sysrc postfix_enable="YES"
  - sysrc sendmail_enable="NONE"

If postfix is *not* already activated in /usr/local/etc/mail/mailer.conf
  - mv /usr/local/etc/mail/mailer.conf /usr/local/etc/mail/mailer.conf.old
  - install -m 0644 /usr/local/share/postfix/mailer.conf.postfix /usr/local/etc/mail/mailer.conf

Disable sendmail(8) specific tasks,
add the following lines to /etc/periodic.conf(.local):
  daily_clean_hoststat_enable="NO"
  daily_status_mail_rejects_enable="NO"
  daily_status_include_submit_mailq="NO"
  daily_submit_queuerun="NO"

If you are using SASL, you need to make sure that postfix has access to read
the sasldb file.  This is accomplished by adding postfix to group mail and
making the /usr/local/etc/sasldb* file(s) readable by group mail (this should
be the default for new installs).

If you are upgrading from prior postfix version, please see the README
files for recommended changes to your configuration and additional
http://www.postfix.org/COMPATIBILITY_README.html

So using that the package gets installed.

So for me working solution will be to force install using batch when you add ‘Force=true’ for example.

I created PR #48730 with this fix.