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

Fix batch install on FreeBSD using pkgng #48730

Merged
merged 4 commits into from
Aug 2, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions salt/modules/pkgng.py
Original file line number Diff line number Diff line change
Expand Up @@ -678,6 +678,7 @@ def install(name=None,
reinstall_requires=False,
regex=False,
pcre=False,
batch=False,
**kwargs):
'''
Install package(s) from a repository
Expand Down Expand Up @@ -801,7 +802,16 @@ def install(name=None,

.. code-block:: bash

salt '*' pkg.install <extended regular expression> pcre=True

batch
Use BATCH=true for pkg install, skipping all questions.
Be careful when using in production.

CLI Example:

.. code-block:: bash

salt '*' pkg.install <package name> batch=True
'''
try:
pkg_params, pkg_type = __salt__['pkg_resource.parse_targets'](
Expand All @@ -813,6 +823,7 @@ def install(name=None,
if pkg_params is None or len(pkg_params) == 0:
return {}

env = {}
opts = 'y'
if salt.utils.data.is_true(orphan):
opts += 'A'
Expand All @@ -832,6 +843,11 @@ def install(name=None,
opts += 'x'
if salt.utils.data.is_true(pcre):
opts += 'X'
if salt.utils.data.is_true(batch):
env = {
"BATCH": "true",
"ASSUME_ALWAYS_YES": "YES"
}

old = list_pkgs(jail=jail, chroot=chroot, root=root)

Expand Down Expand Up @@ -870,7 +886,8 @@ def install(name=None,
out = __salt__['cmd.run_all'](
cmd,
output_loglevel='trace',
python_shell=False
python_shell=False,
env=env
)

if out['retcode'] != 0 and out['stderr']:
Expand Down