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:
Robin Roth 2016-07-09 11:38:12 +02:00 committed by René Moser
parent a99464f545
commit 3480d3d167

View file

@ -157,13 +157,15 @@ def repo_exists(module, repodata, overwrite_multiple):
# Found an existing repo, look for changes # Found an existing repo, look for changes
has_changes = _repo_changes(repos[0], repodata) has_changes = _repo_changes(repos[0], repodata)
return (True, has_changes, repos) return (True, has_changes, repos)
elif len(repos) == 2 and overwrite_multiple: elif len(repos) >= 2:
# Found two repos and want to overwrite_multiple if overwrite_multiple:
return (True, True, repos) # Found two repos and want to overwrite_multiple
else: return (True, True, repos)
# either more than 2 repos (shouldn't happen) else:
# or overwrite_multiple is not active errmsg = 'More than one repo matched "%s": "%s".' % (name, repos)
module.fail_json(msg='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): def modify_repo(module, repodata, old_repos):
repo = repodata['url'] repo = repodata['url']