mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Look for apt-add-repository in PATH instead of assuming it's there
Depending on the ubuntu version, apt-add-repository is provided by different packages. Some versions put it in python-software-properties, and some put it in software-properties-common. It is incorrect to assume it's there because the ``softwareproperties`` python module is available, since it is provided by python-software-properties (and apt-add-repository may or not be also provided by that package).
This commit is contained in:
parent
709d80bb1b
commit
690537ca8b
1 changed files with 7 additions and 4 deletions
|
@ -1451,16 +1451,19 @@ def mod_repo(repo, saltenv='base', **kwargs):
|
|||
# secure PPAs cannot be supported as of the time of this code
|
||||
# implementation via apt-add-repository. The code path for
|
||||
# secure PPAs should be the same as urllib method
|
||||
if HAS_SOFTWAREPROPERTIES and 'ppa_auth' not in kwargs:
|
||||
if salt.utils.which('apt-add-repository') \
|
||||
and 'ppa_auth' not in kwargs:
|
||||
repo_info = get_repo(repo)
|
||||
if repo_info:
|
||||
return {repo: repo_info}
|
||||
else:
|
||||
if float(__grains__['osrelease']) < 12.04:
|
||||
cmd = 'apt-add-repository {0}'.format(_cmd_quote(repo))
|
||||
cmd = ['apt-add-repository', repo]
|
||||
else:
|
||||
cmd = 'apt-add-repository -y {0}'.format(_cmd_quote(repo))
|
||||
out = __salt__['cmd.run_all'](cmd, **kwargs)
|
||||
cmd = ['apt-add-repository', '-y', repo]
|
||||
out = __salt__['cmd.run_all'](cmd,
|
||||
python_shell=False,
|
||||
**kwargs)
|
||||
if out['retcode']:
|
||||
raise CommandExecutionError(
|
||||
'Unable to add PPA {0!r}. '
|
||||
|
|
Loading…
Add table
Reference in a new issue