Allow for creating yum repo based on metalink only (#30736)

pull/30749/merge
Martin Krizek 7 years ago committed by GitHub
parent c3d226a739
commit 8b416abb49

@ -49,7 +49,7 @@ options:
- URL to the directory where the yum repository's 'repodata' directory
lives.
- It can also be a list of multiple URLs.
- This or the I(mirrorlist) parameter is required if I(state) is set to
- This, the I(metalink) or I(mirrorlist) parameters are required if I(state) is set to
C(present).
cost:
required: false
@ -219,12 +219,14 @@ options:
- Specifies a URL to a metalink file for the repomd.xml, a list of
mirrors for the entire repository are generated by converting the
mirrors for the repomd.xml file to a I(baseurl).
- This, the I(baseurl) or I(mirrorlist) parameters are required if I(state) is set to
C(present).
mirrorlist:
required: false
default: null
description:
- Specifies a URL to a file containing a list of baseurls.
- This or the I(baseurl) parameter is required if I(state) is set to
- This, the I(baseurl) or I(metalink) parameters are required if I(state) is set to
C(present).
mirrorlist_expire:
required: false
@ -563,10 +565,11 @@ class YumRepo(object):
# Baseurl/mirrorlist is not required because for removal we need only
# the repo name. This is why we check if the baseurl/mirrorlist is
# defined.
if (self.params['baseurl'], self.params['mirrorlist']) == (None, None):
req_params = (self.params['baseurl'], self.params['metalink'], self.params['mirrorlist'])
if req_params == (None, None, None):
self.module.fail_json(
msg='Parameter "baseurl" or "mirrorlist" is required for '
'adding a new repo.')
msg="Parameter 'baseurl', 'metalink' or 'mirrorlist' is required for "
"adding a new repo.")
# Set options
for key, value in sorted(self.params.items()):
@ -709,9 +712,10 @@ def main():
if state == 'present':
if (
module.params['baseurl'] is None and
module.params['metalink'] is None and
module.params['mirrorlist'] is None):
module.fail_json(
msg="Parameter 'baseurl' or 'mirrorlist' is required.")
msg="Parameter 'baseurl', 'metalink' or 'mirrorlist' is required.")
if module.params['description'] is None:
module.fail_json(
msg="Parameter 'description' is required.")

Loading…
Cancel
Save