allow overwrite_multiple with more than 2 repos (#2481)
2.1 introduces overwrite_multiple, which can overwrite more than one exisiting repo (with matching alias or URL). Allow more than 2 repos to be overwritten, since openSuSE allow more than one repo with the same URL if the alias is different.
This commit is contained in:
parent
04d049cee9
commit
6fdad49309
1 changed files with 9 additions and 7 deletions
|
@ -157,13 +157,15 @@ def repo_exists(module, repodata, overwrite_multiple):
|
|||
# Found an existing repo, look for changes
|
||||
has_changes = _repo_changes(repos[0], repodata)
|
||||
return (True, has_changes, repos)
|
||||
elif len(repos) == 2 and overwrite_multiple:
|
||||
# Found two repos and want to overwrite_multiple
|
||||
return (True, True, repos)
|
||||
else:
|
||||
# either more than 2 repos (shouldn't happen)
|
||||
# or overwrite_multiple is not active
|
||||
module.fail_json(msg='More than one repo matched "%s": "%s"' % (name, repos))
|
||||
elif len(repos) >= 2:
|
||||
if overwrite_multiple:
|
||||
# Found two repos and want to overwrite_multiple
|
||||
return (True, True, repos)
|
||||
else:
|
||||
errmsg = 'More than one repo matched "%s": "%s".' % (name, repos)
|
||||
errmsg += ' Use overwrite_multiple to allow more than one repo to be overwritten'
|
||||
module.fail_json(msg=errmsg)
|
||||
|
||||
|
||||
def modify_repo(module, repodata, old_repos):
|
||||
repo = repodata['url']
|
||||
|
|
Loading…
Reference in a new issue