Add additional auth support to Gitlab (#705) (#3918)

* Add additional auth support to Gitlab (#705)

- removed unused imports from module_utils.gitlab
- fix bug in gitlab_project to check if avatar_path is provided

* add doc_fragment and argument_spec for gitlab auth

* doc fixes and remove avatar_path bug fix

* small doc changes, pass validate_certs to requests call

* update changelog
This commit is contained in:
Josh 2021-12-20 15:59:12 -05:00 committed by GitHub
parent 11fcf661bf
commit 52ad0a5fbb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 298 additions and 250 deletions

View file

@ -24,6 +24,7 @@ requirements:
- python-gitlab python module
extends_documentation_fragment:
- community.general.auth_basic
- community.general.gitlab
options:
state:
@ -32,11 +33,6 @@ options:
default: present
type: str
choices: ["present", "absent"]
api_token:
description:
- GitLab access token with API permissions.
required: true
type: str
group:
description:
- The path and name of the group.
@ -144,7 +140,7 @@ except Exception:
GITLAB_IMP_ERR = traceback.format_exc()
HAS_GITLAB_PACKAGE = False
from ansible_collections.community.general.plugins.module_utils.gitlab import gitlab_authentication
from ansible_collections.community.general.plugins.module_utils.gitlab import auth_argument_spec, gitlab_authentication
class GitlabGroupVariables(object):
@ -268,8 +264,8 @@ def native_python_main(this_gitlab, purge, var_list, state, module):
def main():
argument_spec = basic_auth_argument_spec()
argument_spec.update(auth_argument_spec())
argument_spec.update(
api_token=dict(type='str', required=True, no_log=True),
group=dict(type='str', required=True),
purge=dict(type='bool', required=False, default=False),
vars=dict(type='dict', required=False, default=dict(), no_log=True),
@ -280,13 +276,16 @@ def main():
argument_spec=argument_spec,
mutually_exclusive=[
['api_username', 'api_token'],
['api_password', 'api_token'],
['api_username', 'api_oauth_token'],
['api_username', 'api_job_token'],
['api_token', 'api_oauth_token'],
['api_token', 'api_job_token'],
],
required_together=[
['api_username', 'api_password'],
],
required_one_of=[
['api_username', 'api_token']
['api_username', 'api_token', 'api_oauth_token', 'api_job_token']
],
supports_check_mode=True
)