Merge pull request #48896 from rallytime/bp-48730

Back-port #48730 to 2017.7
This commit is contained in:
Nicole Thomas 2018-08-05 14:20:39 -04:00 committed by GitHub
commit 5f6a56f5dc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -671,6 +671,7 @@ def install(name=None,
reinstall_requires=False,
regex=False,
pcre=False,
batch=False,
**kwargs):
'''
Install package(s) from a repository
@ -794,7 +795,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'](
@ -806,6 +816,7 @@ def install(name=None,
if pkg_params is None or len(pkg_params) == 0:
return {}
env = {}
opts = 'y'
if salt.utils.is_true(orphan):
opts += 'A'
@ -825,6 +836,11 @@ def install(name=None,
opts += 'x'
if salt.utils.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)
@ -861,7 +877,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']: