mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-22 10:21:25 -07:00
gitlab modules: do not crash if python-gitlab isn't there (#8158)
Do not crash if python-gitlab isn't there.
This commit is contained in:
parent
b2b8fc30bf
commit
b463571902
5 changed files with 17 additions and 30 deletions
|
@ -81,16 +81,23 @@ def find_group(gitlab_instance, identifier):
|
|||
return group
|
||||
|
||||
|
||||
def ensure_gitlab_package(module):
|
||||
def ensure_gitlab_package(module, min_version=None):
|
||||
if not HAS_GITLAB_PACKAGE:
|
||||
module.fail_json(
|
||||
msg=missing_required_lib("python-gitlab", url='https://python-gitlab.readthedocs.io/en/stable/'),
|
||||
exception=GITLAB_IMP_ERR
|
||||
)
|
||||
gitlab_version = gitlab.__version__
|
||||
if min_version is not None and LooseVersion(gitlab_version) < LooseVersion(min_version):
|
||||
module.fail_json(
|
||||
msg="This module requires python-gitlab Python module >= %s "
|
||||
"(installed version: %s). Please upgrade python-gitlab to version %s or above."
|
||||
% (min_version, gitlab_version, min_version)
|
||||
)
|
||||
|
||||
|
||||
def gitlab_authentication(module):
|
||||
ensure_gitlab_package(module)
|
||||
def gitlab_authentication(module, min_version=None):
|
||||
ensure_gitlab_package(module, min_version=min_version)
|
||||
|
||||
gitlab_url = module.params['api_url']
|
||||
validate_certs = module.params['validate_certs']
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue