1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

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 Matt Clay
parent 04d049cee9
commit 6fdad49309

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']