Fix typesetting of "GitLab" (#61702)
This commit is contained in:
parent
74e6c460b4
commit
7dbd6116d8
17 changed files with 85 additions and 85 deletions
|
@ -31,7 +31,7 @@ extends_documentation_fragment:
|
||||||
options:
|
options:
|
||||||
api_token:
|
api_token:
|
||||||
description:
|
description:
|
||||||
- Gitlab token for logging in.
|
- GitLab token for logging in.
|
||||||
version_added: "2.8"
|
version_added: "2.8"
|
||||||
type: str
|
type: str
|
||||||
aliases:
|
aliases:
|
||||||
|
@ -109,7 +109,7 @@ result:
|
||||||
type: dict
|
type: dict
|
||||||
|
|
||||||
error:
|
error:
|
||||||
description: the error message returned by the Gitlab API
|
description: the error message returned by the GitLab API
|
||||||
returned: failed
|
returned: failed
|
||||||
type: str
|
type: str
|
||||||
sample: "400: key is already in use"
|
sample: "400: key is already in use"
|
||||||
|
@ -292,10 +292,10 @@ def main():
|
||||||
private_token=gitlab_token, api_version=4)
|
private_token=gitlab_token, api_version=4)
|
||||||
gitlab_instance.auth()
|
gitlab_instance.auth()
|
||||||
except (gitlab.exceptions.GitlabAuthenticationError, gitlab.exceptions.GitlabGetError) as e:
|
except (gitlab.exceptions.GitlabAuthenticationError, gitlab.exceptions.GitlabGetError) as e:
|
||||||
module.fail_json(msg="Failed to connect to Gitlab server: %s" % to_native(e))
|
module.fail_json(msg="Failed to connect to GitLab server: %s" % to_native(e))
|
||||||
except (gitlab.exceptions.GitlabHttpError) as e:
|
except (gitlab.exceptions.GitlabHttpError) as e:
|
||||||
module.fail_json(msg="Failed to connect to Gitlab server: %s. \
|
module.fail_json(msg="Failed to connect to GitLab server: %s. \
|
||||||
Gitlab remove Session API now that private tokens are removed from user API endpoints since version 10.2." % to_native(e))
|
GitLab remove Session API now that private tokens are removed from user API endpoints since version 10.2." % to_native(e))
|
||||||
|
|
||||||
gitlab_deploy_key = GitLabDeployKey(module, gitlab_instance)
|
gitlab_deploy_key = GitLabDeployKey(module, gitlab_instance)
|
||||||
|
|
||||||
|
|
|
@ -15,9 +15,9 @@ ANSIBLE_METADATA = {'metadata_version': '1.1',
|
||||||
DOCUMENTATION = '''
|
DOCUMENTATION = '''
|
||||||
---
|
---
|
||||||
module: gitlab_group
|
module: gitlab_group
|
||||||
short_description: Creates/updates/deletes Gitlab Groups
|
short_description: Creates/updates/deletes GitLab Groups
|
||||||
description:
|
description:
|
||||||
- When the group does not exist in Gitlab, it will be created.
|
- When the group does not exist in GitLab, it will be created.
|
||||||
- When the group does exist and state=absent, the group will be deleted.
|
- When the group does exist and state=absent, the group will be deleted.
|
||||||
version_added: "2.1"
|
version_added: "2.1"
|
||||||
author:
|
author:
|
||||||
|
@ -31,20 +31,20 @@ extends_documentation_fragment:
|
||||||
options:
|
options:
|
||||||
server_url:
|
server_url:
|
||||||
description:
|
description:
|
||||||
- The URL of the Gitlab server, with protocol (i.e. http or https).
|
- The URL of the GitLab server, with protocol (i.e. http or https).
|
||||||
required: true
|
required: true
|
||||||
type: str
|
type: str
|
||||||
login_user:
|
login_user:
|
||||||
description:
|
description:
|
||||||
- Gitlab user name.
|
- GitLab user name.
|
||||||
type: str
|
type: str
|
||||||
login_password:
|
login_password:
|
||||||
description:
|
description:
|
||||||
- Gitlab password for login_user
|
- GitLab password for login_user
|
||||||
type: str
|
type: str
|
||||||
api_token:
|
api_token:
|
||||||
description:
|
description:
|
||||||
- Gitlab token for logging in.
|
- GitLab token for logging in.
|
||||||
type: str
|
type: str
|
||||||
aliases:
|
aliases:
|
||||||
- login_token
|
- login_token
|
||||||
|
@ -86,7 +86,7 @@ options:
|
||||||
'''
|
'''
|
||||||
|
|
||||||
EXAMPLES = '''
|
EXAMPLES = '''
|
||||||
- name: "Delete Gitlab Group"
|
- name: "Delete GitLab Group"
|
||||||
gitlab_group:
|
gitlab_group:
|
||||||
api_url: https://gitlab.example.com/
|
api_url: https://gitlab.example.com/
|
||||||
api_token: "{{ access_token }}"
|
api_token: "{{ access_token }}"
|
||||||
|
@ -94,7 +94,7 @@ EXAMPLES = '''
|
||||||
name: my_first_group
|
name: my_first_group
|
||||||
state: absent
|
state: absent
|
||||||
|
|
||||||
- name: "Create Gitlab Group"
|
- name: "Create GitLab Group"
|
||||||
gitlab_group:
|
gitlab_group:
|
||||||
api_url: https://gitlab.example.com/
|
api_url: https://gitlab.example.com/
|
||||||
validate_certs: True
|
validate_certs: True
|
||||||
|
@ -105,7 +105,7 @@ EXAMPLES = '''
|
||||||
state: present
|
state: present
|
||||||
|
|
||||||
# The group will by created at https://gitlab.dj-wasabi.local/super_parent/parent/my_first_group
|
# The group will by created at https://gitlab.dj-wasabi.local/super_parent/parent/my_first_group
|
||||||
- name: "Create Gitlab SubGroup"
|
- name: "Create GitLab SubGroup"
|
||||||
gitlab_group:
|
gitlab_group:
|
||||||
api_url: https://gitlab.example.com/
|
api_url: https://gitlab.example.com/
|
||||||
validate_certs: True
|
validate_certs: True
|
||||||
|
@ -130,7 +130,7 @@ result:
|
||||||
type: dict
|
type: dict
|
||||||
|
|
||||||
error:
|
error:
|
||||||
description: the error message returned by the Gitlab API
|
description: the error message returned by the GitLab API
|
||||||
returned: failed
|
returned: failed
|
||||||
type: str
|
type: str
|
||||||
sample: "400: path is already in use"
|
sample: "400: path is already in use"
|
||||||
|
@ -340,10 +340,10 @@ def main():
|
||||||
private_token=gitlab_token, api_version=4)
|
private_token=gitlab_token, api_version=4)
|
||||||
gitlab_instance.auth()
|
gitlab_instance.auth()
|
||||||
except (gitlab.exceptions.GitlabAuthenticationError, gitlab.exceptions.GitlabGetError) as e:
|
except (gitlab.exceptions.GitlabAuthenticationError, gitlab.exceptions.GitlabGetError) as e:
|
||||||
module.fail_json(msg="Failed to connect to Gitlab server: %s" % to_native(e))
|
module.fail_json(msg="Failed to connect to GitLab server: %s" % to_native(e))
|
||||||
except (gitlab.exceptions.GitlabHttpError) as e:
|
except (gitlab.exceptions.GitlabHttpError) as e:
|
||||||
module.fail_json(msg="Failed to connect to Gitlab server: %s. \
|
module.fail_json(msg="Failed to connect to GitLab server: %s. \
|
||||||
Gitlab remove Session API now that private tokens are removed from user API endpoints since version 10.2" % to_native(e))
|
GitLab remove Session API now that private tokens are removed from user API endpoints since version 10.2" % to_native(e))
|
||||||
|
|
||||||
# Define default group_path based on group_name
|
# Define default group_path based on group_name
|
||||||
if group_path is None:
|
if group_path is None:
|
||||||
|
@ -355,7 +355,7 @@ def main():
|
||||||
if parent_identifier:
|
if parent_identifier:
|
||||||
parent_group = findGroup(gitlab_instance, parent_identifier)
|
parent_group = findGroup(gitlab_instance, parent_identifier)
|
||||||
if not parent_group:
|
if not parent_group:
|
||||||
module.fail_json(msg="Failed create Gitlab group: Parent group doesn't exists")
|
module.fail_json(msg="Failed create GitLab group: Parent group doesn't exists")
|
||||||
|
|
||||||
group_exists = gitlab_group.existsGroup(parent_group.full_path + '/' + group_path)
|
group_exists = gitlab_group.existsGroup(parent_group.full_path + '/' + group_path)
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -32,7 +32,7 @@ extends_documentation_fragment:
|
||||||
options:
|
options:
|
||||||
api_token:
|
api_token:
|
||||||
description:
|
description:
|
||||||
- Gitlab token for logging in.
|
- GitLab token for logging in.
|
||||||
version_added: "2.8"
|
version_added: "2.8"
|
||||||
type: str
|
type: str
|
||||||
aliases:
|
aliases:
|
||||||
|
@ -105,7 +105,7 @@ options:
|
||||||
description:
|
description:
|
||||||
- Secret token to validate hook messages at the receiver.
|
- Secret token to validate hook messages at the receiver.
|
||||||
- If this is present it will always result in a change as it cannot be retrieved from GitLab.
|
- If this is present it will always result in a change as it cannot be retrieved from GitLab.
|
||||||
- Will show up in the X-Gitlab-Token HTTP request header
|
- Will show up in the X-GitLab-Token HTTP request header
|
||||||
required: false
|
required: false
|
||||||
type: str
|
type: str
|
||||||
'''
|
'''
|
||||||
|
@ -153,7 +153,7 @@ result:
|
||||||
type: dict
|
type: dict
|
||||||
|
|
||||||
error:
|
error:
|
||||||
description: the error message returned by the Gitlab API
|
description: the error message returned by the GitLab API
|
||||||
returned: failed
|
returned: failed
|
||||||
type: str
|
type: str
|
||||||
sample: "400: path is already in use"
|
sample: "400: path is already in use"
|
||||||
|
@ -365,10 +365,10 @@ def main():
|
||||||
private_token=gitlab_token, api_version=4)
|
private_token=gitlab_token, api_version=4)
|
||||||
gitlab_instance.auth()
|
gitlab_instance.auth()
|
||||||
except (gitlab.exceptions.GitlabAuthenticationError, gitlab.exceptions.GitlabGetError) as e:
|
except (gitlab.exceptions.GitlabAuthenticationError, gitlab.exceptions.GitlabGetError) as e:
|
||||||
module.fail_json(msg="Failed to connect to Gitlab server: %s" % to_native(e))
|
module.fail_json(msg="Failed to connect to GitLab server: %s" % to_native(e))
|
||||||
except (gitlab.exceptions.GitlabHttpError) as e:
|
except (gitlab.exceptions.GitlabHttpError) as e:
|
||||||
module.fail_json(msg="Failed to connect to Gitlab server: %s. \
|
module.fail_json(msg="Failed to connect to GitLab server: %s. \
|
||||||
Gitlab remove Session API now that private tokens are removed from user API endpoints since version 10.2." % to_native(e))
|
GitLab remove Session API now that private tokens are removed from user API endpoints since version 10.2." % to_native(e))
|
||||||
|
|
||||||
gitlab_hook = GitLabHook(module, gitlab_instance)
|
gitlab_hook = GitLabHook(module, gitlab_instance)
|
||||||
|
|
||||||
|
|
|
@ -15,9 +15,9 @@ ANSIBLE_METADATA = {'metadata_version': '1.1',
|
||||||
DOCUMENTATION = '''
|
DOCUMENTATION = '''
|
||||||
---
|
---
|
||||||
module: gitlab_project
|
module: gitlab_project
|
||||||
short_description: Creates/updates/deletes Gitlab Projects
|
short_description: Creates/updates/deletes GitLab Projects
|
||||||
description:
|
description:
|
||||||
- When the project does not exist in Gitlab, it will be created.
|
- When the project does not exist in GitLab, it will be created.
|
||||||
- When the project does exists and state=absent, the project will be deleted.
|
- When the project does exists and state=absent, the project will be deleted.
|
||||||
- When changes are made to the project, the project will be updated.
|
- When changes are made to the project, the project will be updated.
|
||||||
version_added: "2.1"
|
version_added: "2.1"
|
||||||
|
@ -32,20 +32,20 @@ extends_documentation_fragment:
|
||||||
options:
|
options:
|
||||||
server_url:
|
server_url:
|
||||||
description:
|
description:
|
||||||
- The URL of the Gitlab server, with protocol (i.e. http or https).
|
- The URL of the GitLab server, with protocol (i.e. http or https).
|
||||||
required: true
|
required: true
|
||||||
type: str
|
type: str
|
||||||
login_user:
|
login_user:
|
||||||
description:
|
description:
|
||||||
- Gitlab user name.
|
- GitLab user name.
|
||||||
type: str
|
type: str
|
||||||
login_password:
|
login_password:
|
||||||
description:
|
description:
|
||||||
- Gitlab password for login_user
|
- GitLab password for login_user
|
||||||
type: str
|
type: str
|
||||||
api_token:
|
api_token:
|
||||||
description:
|
description:
|
||||||
- Gitlab token for logging in.
|
- GitLab token for logging in.
|
||||||
type: str
|
type: str
|
||||||
aliases:
|
aliases:
|
||||||
- login_token
|
- login_token
|
||||||
|
@ -104,7 +104,7 @@ options:
|
||||||
import_url:
|
import_url:
|
||||||
description:
|
description:
|
||||||
- Git repository which will be imported into gitlab.
|
- Git repository which will be imported into gitlab.
|
||||||
- Gitlab server needs read access to this git repository.
|
- GitLab server needs read access to this git repository.
|
||||||
required: false
|
required: false
|
||||||
type: str
|
type: str
|
||||||
state:
|
state:
|
||||||
|
@ -117,7 +117,7 @@ options:
|
||||||
'''
|
'''
|
||||||
|
|
||||||
EXAMPLES = '''
|
EXAMPLES = '''
|
||||||
- name: Delete Gitlab Project
|
- name: Delete GitLab Project
|
||||||
gitlab_project:
|
gitlab_project:
|
||||||
api_url: https://gitlab.example.com/
|
api_url: https://gitlab.example.com/
|
||||||
api_token: "{{ access_token }}"
|
api_token: "{{ access_token }}"
|
||||||
|
@ -126,7 +126,7 @@ EXAMPLES = '''
|
||||||
state: absent
|
state: absent
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
|
|
||||||
- name: Create Gitlab Project in group Ansible
|
- name: Create GitLab Project in group Ansible
|
||||||
gitlab_project:
|
gitlab_project:
|
||||||
api_url: https://gitlab.example.com/
|
api_url: https://gitlab.example.com/
|
||||||
validate_certs: True
|
validate_certs: True
|
||||||
|
@ -155,7 +155,7 @@ result:
|
||||||
type: dict
|
type: dict
|
||||||
|
|
||||||
error:
|
error:
|
||||||
description: the error message returned by the Gitlab API
|
description: the error message returned by the GitLab API
|
||||||
returned: failed
|
returned: failed
|
||||||
type: str
|
type: str
|
||||||
sample: "400: path is already in use"
|
sample: "400: path is already in use"
|
||||||
|
@ -369,10 +369,10 @@ def main():
|
||||||
private_token=gitlab_token, api_version=4)
|
private_token=gitlab_token, api_version=4)
|
||||||
gitlab_instance.auth()
|
gitlab_instance.auth()
|
||||||
except (gitlab.exceptions.GitlabAuthenticationError, gitlab.exceptions.GitlabGetError) as e:
|
except (gitlab.exceptions.GitlabAuthenticationError, gitlab.exceptions.GitlabGetError) as e:
|
||||||
module.fail_json(msg="Failed to connect to Gitlab server: %s" % to_native(e))
|
module.fail_json(msg="Failed to connect to GitLab server: %s" % to_native(e))
|
||||||
except (gitlab.exceptions.GitlabHttpError) as e:
|
except (gitlab.exceptions.GitlabHttpError) as e:
|
||||||
module.fail_json(msg="Failed to connect to Gitlab server: %s. \
|
module.fail_json(msg="Failed to connect to GitLab server: %s. \
|
||||||
Gitlab remove Session API now that private tokens are removed from user API endpoints since version 10.2." % to_native(e))
|
GitLab remove Session API now that private tokens are removed from user API endpoints since version 10.2." % to_native(e))
|
||||||
|
|
||||||
# Set project_path to project_name if it is empty.
|
# Set project_path to project_name if it is empty.
|
||||||
if project_path is None:
|
if project_path is None:
|
||||||
|
|
|
@ -240,8 +240,8 @@ def main():
|
||||||
except (gitlab.exceptions.GitlabAuthenticationError, gitlab.exceptions.GitlabGetError) as e:
|
except (gitlab.exceptions.GitlabAuthenticationError, gitlab.exceptions.GitlabGetError) as e:
|
||||||
module.fail_json(msg="Failed to connect to GitLab server: %s" % to_native(e))
|
module.fail_json(msg="Failed to connect to GitLab server: %s" % to_native(e))
|
||||||
except (gitlab.exceptions.GitlabHttpError) as e:
|
except (gitlab.exceptions.GitlabHttpError) as e:
|
||||||
module.fail_json(msg="Failed to connect to Gitlab server: %s. \
|
module.fail_json(msg="Failed to connect to GitLab server: %s. \
|
||||||
Gitlab remove Session API now that private tokens are removed from user API endpoints since version 10.2" % to_native(e))
|
GitLab remove Session API now that private tokens are removed from user API endpoints since version 10.2" % to_native(e))
|
||||||
|
|
||||||
this_gitlab = GitlabProjectVariables(module=module, gitlab_instance=gitlab_instance)
|
this_gitlab = GitlabProjectVariables(module=module, gitlab_instance=gitlab_instance)
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@ extends_documentation_fragment:
|
||||||
options:
|
options:
|
||||||
url:
|
url:
|
||||||
description:
|
description:
|
||||||
- The URL of the Gitlab server, with protocol (i.e. http or https).
|
- The URL of the GitLab server, with protocol (i.e. http or https).
|
||||||
required: true
|
required: true
|
||||||
type: str
|
type: str
|
||||||
api_token:
|
api_token:
|
||||||
|
@ -141,7 +141,7 @@ result:
|
||||||
type: dict
|
type: dict
|
||||||
|
|
||||||
error:
|
error:
|
||||||
description: the error message returned by the Gitlab API
|
description: the error message returned by the GitLab API
|
||||||
returned: failed
|
returned: failed
|
||||||
type: str
|
type: str
|
||||||
sample: "400: path is already in use"
|
sample: "400: path is already in use"
|
||||||
|
@ -354,10 +354,10 @@ def main():
|
||||||
private_token=gitlab_token, api_version=4)
|
private_token=gitlab_token, api_version=4)
|
||||||
gitlab_instance.auth()
|
gitlab_instance.auth()
|
||||||
except (gitlab.exceptions.GitlabAuthenticationError, gitlab.exceptions.GitlabGetError) as e:
|
except (gitlab.exceptions.GitlabAuthenticationError, gitlab.exceptions.GitlabGetError) as e:
|
||||||
module.fail_json(msg="Failed to connect to Gitlab server: %s" % to_native(e))
|
module.fail_json(msg="Failed to connect to GitLab server: %s" % to_native(e))
|
||||||
except (gitlab.exceptions.GitlabHttpError) as e:
|
except (gitlab.exceptions.GitlabHttpError) as e:
|
||||||
module.fail_json(msg="Failed to connect to Gitlab server: %s. \
|
module.fail_json(msg="Failed to connect to GitLab server: %s. \
|
||||||
Gitlab remove Session API now that private tokens are removed from user API endpoints since version 10.2" % to_native(e))
|
GitLab remove Session API now that private tokens are removed from user API endpoints since version 10.2" % to_native(e))
|
||||||
|
|
||||||
gitlab_runner = GitLabRunner(module, gitlab_instance)
|
gitlab_runner = GitLabRunner(module, gitlab_instance)
|
||||||
runner_exists = gitlab_runner.existsRunner(runner_description)
|
runner_exists = gitlab_runner.existsRunner(runner_description)
|
||||||
|
|
|
@ -15,9 +15,9 @@ ANSIBLE_METADATA = {'metadata_version': '1.1',
|
||||||
DOCUMENTATION = '''
|
DOCUMENTATION = '''
|
||||||
---
|
---
|
||||||
module: gitlab_user
|
module: gitlab_user
|
||||||
short_description: Creates/updates/deletes Gitlab Users
|
short_description: Creates/updates/deletes GitLab Users
|
||||||
description:
|
description:
|
||||||
- When the user does not exist in Gitlab, it will be created.
|
- When the user does not exist in GitLab, it will be created.
|
||||||
- When the user does exists and state=absent, the user will be deleted.
|
- When the user does exists and state=absent, the user will be deleted.
|
||||||
- When changes are made to user, the user will be updated.
|
- When changes are made to user, the user will be updated.
|
||||||
version_added: "2.1"
|
version_added: "2.1"
|
||||||
|
@ -27,26 +27,26 @@ author:
|
||||||
requirements:
|
requirements:
|
||||||
- python >= 2.7
|
- python >= 2.7
|
||||||
- python-gitlab python module
|
- python-gitlab python module
|
||||||
- administrator rights on the Gitlab server
|
- administrator rights on the GitLab server
|
||||||
extends_documentation_fragment:
|
extends_documentation_fragment:
|
||||||
- auth_basic
|
- auth_basic
|
||||||
options:
|
options:
|
||||||
server_url:
|
server_url:
|
||||||
description:
|
description:
|
||||||
- The URL of the Gitlab server, with protocol (i.e. http or https).
|
- The URL of the GitLab server, with protocol (i.e. http or https).
|
||||||
required: true
|
required: true
|
||||||
type: str
|
type: str
|
||||||
login_user:
|
login_user:
|
||||||
description:
|
description:
|
||||||
- Gitlab user name.
|
- GitLab user name.
|
||||||
type: str
|
type: str
|
||||||
login_password:
|
login_password:
|
||||||
description:
|
description:
|
||||||
- Gitlab password for login_user
|
- GitLab password for login_user
|
||||||
type: str
|
type: str
|
||||||
api_token:
|
api_token:
|
||||||
description:
|
description:
|
||||||
- Gitlab token for logging in.
|
- GitLab token for logging in.
|
||||||
type: str
|
type: str
|
||||||
aliases:
|
aliases:
|
||||||
- login_token
|
- login_token
|
||||||
|
@ -124,7 +124,7 @@ options:
|
||||||
'''
|
'''
|
||||||
|
|
||||||
EXAMPLES = '''
|
EXAMPLES = '''
|
||||||
- name: "Delete Gitlab User"
|
- name: "Delete GitLab User"
|
||||||
gitlab_user:
|
gitlab_user:
|
||||||
api_url: https://gitlab.example.com/
|
api_url: https://gitlab.example.com/
|
||||||
api_token: "{{ access_token }}"
|
api_token: "{{ access_token }}"
|
||||||
|
@ -133,7 +133,7 @@ EXAMPLES = '''
|
||||||
state: absent
|
state: absent
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
|
|
||||||
- name: "Create Gitlab User"
|
- name: "Create GitLab User"
|
||||||
gitlab_user:
|
gitlab_user:
|
||||||
api_url: https://gitlab.example.com/
|
api_url: https://gitlab.example.com/
|
||||||
validate_certs: True
|
validate_certs: True
|
||||||
|
@ -164,7 +164,7 @@ result:
|
||||||
type: dict
|
type: dict
|
||||||
|
|
||||||
error:
|
error:
|
||||||
description: the error message returned by the Gitlab API
|
description: the error message returned by the GitLab API
|
||||||
returned: failed
|
returned: failed
|
||||||
type: str
|
type: str
|
||||||
sample: "400: path is already in use"
|
sample: "400: path is already in use"
|
||||||
|
@ -313,7 +313,7 @@ class GitLabUser(object):
|
||||||
'''
|
'''
|
||||||
@param group Group object
|
@param group Group object
|
||||||
@param user_id Id of the user to check
|
@param user_id Id of the user to check
|
||||||
@param access_level Gitlab access_level to check
|
@param access_level GitLab access_level to check
|
||||||
'''
|
'''
|
||||||
def memberAsGoodAccessLevel(self, group, user_id, access_level):
|
def memberAsGoodAccessLevel(self, group, user_id, access_level):
|
||||||
member = self.findMember(group, user_id)
|
member = self.findMember(group, user_id)
|
||||||
|
@ -323,7 +323,7 @@ class GitLabUser(object):
|
||||||
'''
|
'''
|
||||||
@param user User object
|
@param user User object
|
||||||
@param group_path Complete path of the Group including parent group path. <parent_path>/<group_path>
|
@param group_path Complete path of the Group including parent group path. <parent_path>/<group_path>
|
||||||
@param access_level Gitlab access_level to assign
|
@param access_level GitLab access_level to assign
|
||||||
'''
|
'''
|
||||||
def assignUserToGroup(self, user, group_identifier, access_level):
|
def assignUserToGroup(self, user, group_identifier, access_level):
|
||||||
group = findGroup(self._gitlab, group_identifier)
|
group = findGroup(self._gitlab, group_identifier)
|
||||||
|
@ -493,10 +493,10 @@ def main():
|
||||||
private_token=gitlab_token, api_version=4)
|
private_token=gitlab_token, api_version=4)
|
||||||
gitlab_instance.auth()
|
gitlab_instance.auth()
|
||||||
except (gitlab.exceptions.GitlabAuthenticationError, gitlab.exceptions.GitlabGetError) as e:
|
except (gitlab.exceptions.GitlabAuthenticationError, gitlab.exceptions.GitlabGetError) as e:
|
||||||
module.fail_json(msg="Failed to connect to Gitlab server: %s" % to_native(e))
|
module.fail_json(msg="Failed to connect to GitLab server: %s" % to_native(e))
|
||||||
except (gitlab.exceptions.GitlabHttpError) as e:
|
except (gitlab.exceptions.GitlabHttpError) as e:
|
||||||
module.fail_json(msg="Failed to connect to Gitlab server: %s. \
|
module.fail_json(msg="Failed to connect to GitLab server: %s. \
|
||||||
Gitlab remove Session API now that private tokens are removed from user API endpoints since version 10.2." % to_native(e))
|
GitLab remove Session API now that private tokens are removed from user API endpoints since version 10.2." % to_native(e))
|
||||||
|
|
||||||
gitlab_user = GitLabUser(module, gitlab_instance)
|
gitlab_user = GitLabUser(module, gitlab_instance)
|
||||||
user_exists = gitlab_user.existsUser(user_username)
|
user_exists = gitlab_user.existsUser(user_username)
|
||||||
|
|
|
@ -13,14 +13,14 @@ DOCUMENTATION = '''
|
||||||
version_added: '2.8'
|
version_added: '2.8'
|
||||||
authors:
|
authors:
|
||||||
- Stefan Heitmüller (stefan.heitmueller@gmx.com)
|
- Stefan Heitmüller (stefan.heitmueller@gmx.com)
|
||||||
short_description: Ansible dynamic inventory plugin for Gitlab runners.
|
short_description: Ansible dynamic inventory plugin for GitLab runners.
|
||||||
requirements:
|
requirements:
|
||||||
- python >= 2.7
|
- python >= 2.7
|
||||||
- python-gitlab > 1.8.0
|
- python-gitlab > 1.8.0
|
||||||
extends_documentation_fragment:
|
extends_documentation_fragment:
|
||||||
- constructed
|
- constructed
|
||||||
description:
|
description:
|
||||||
- Reads inventories from the Gitlab API.
|
- Reads inventories from the GitLab API.
|
||||||
- Uses a YAML configuration file gitlab_runners.[yml|yaml].
|
- Uses a YAML configuration file gitlab_runners.[yml|yaml].
|
||||||
options:
|
options:
|
||||||
plugin:
|
plugin:
|
||||||
|
@ -30,18 +30,18 @@ DOCUMENTATION = '''
|
||||||
choices:
|
choices:
|
||||||
- gitlab_runners
|
- gitlab_runners
|
||||||
server_url:
|
server_url:
|
||||||
description: The URL of the Gitlab server, with protocol (i.e. http or https).
|
description: The URL of the GitLab server, with protocol (i.e. http or https).
|
||||||
type: str
|
type: str
|
||||||
required: true
|
required: true
|
||||||
default: https://gitlab.com
|
default: https://gitlab.com
|
||||||
api_token:
|
api_token:
|
||||||
description: Gitlab token for logging in.
|
description: GitLab token for logging in.
|
||||||
type: str
|
type: str
|
||||||
aliases:
|
aliases:
|
||||||
- private_token
|
- private_token
|
||||||
- access_token
|
- access_token
|
||||||
filter:
|
filter:
|
||||||
description: filter runners from Gitlab API
|
description: filter runners from GitLab API
|
||||||
type: str
|
type: str
|
||||||
choices: ['active', 'paused', 'online', 'specific', 'shared']
|
choices: ['active', 'paused', 'online', 'specific', 'shared']
|
||||||
verbose_output:
|
verbose_output:
|
||||||
|
@ -85,7 +85,7 @@ except ImportError:
|
||||||
|
|
||||||
|
|
||||||
class InventoryModule(BaseInventoryPlugin, Constructable):
|
class InventoryModule(BaseInventoryPlugin, Constructable):
|
||||||
''' Host inventory parser for ansible using Gitlab API as source. '''
|
''' Host inventory parser for ansible using GitLab API as source. '''
|
||||||
|
|
||||||
NAME = 'gitlab_runners'
|
NAME = 'gitlab_runners'
|
||||||
|
|
||||||
|
@ -115,7 +115,7 @@ class InventoryModule(BaseInventoryPlugin, Constructable):
|
||||||
# Create groups based on variable values and add the corresponding hosts to it
|
# Create groups based on variable values and add the corresponding hosts to it
|
||||||
self._add_host_to_keyed_groups(self.get_option('keyed_groups'), host_attrs, host, strict=strict)
|
self._add_host_to_keyed_groups(self.get_option('keyed_groups'), host_attrs, host, strict=strict)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise AnsibleParserError('Unable to fetch hosts from Gitlab API, this was the original exception: %s' % to_native(e))
|
raise AnsibleParserError('Unable to fetch hosts from GitLab API, this was the original exception: %s' % to_native(e))
|
||||||
|
|
||||||
def verify_file(self, path):
|
def verify_file(self, path):
|
||||||
"""Return the possibly of a file being consumable by this plugin."""
|
"""Return the possibly of a file being consumable by this plugin."""
|
||||||
|
@ -125,7 +125,7 @@ class InventoryModule(BaseInventoryPlugin, Constructable):
|
||||||
|
|
||||||
def parse(self, inventory, loader, path, cache=True):
|
def parse(self, inventory, loader, path, cache=True):
|
||||||
if not HAS_GITLAB:
|
if not HAS_GITLAB:
|
||||||
raise AnsibleError('The Gitlab runners dynamic inventory plugin requires python-gitlab: https://python-gitlab.readthedocs.io/en/stable/')
|
raise AnsibleError('The GitLab runners dynamic inventory plugin requires python-gitlab: https://python-gitlab.readthedocs.io/en/stable/')
|
||||||
super(InventoryModule, self).parse(inventory, loader, path, cache)
|
super(InventoryModule, self).parse(inventory, loader, path, cache)
|
||||||
self._read_config_data(path)
|
self._read_config_data(path)
|
||||||
self._populate()
|
self._populate()
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
name: python-gitlab
|
name: python-gitlab
|
||||||
state: present
|
state: present
|
||||||
|
|
||||||
- name: Cleanup Gitlab Group
|
- name: Cleanup GitLab Group
|
||||||
gitlab_group:
|
gitlab_group:
|
||||||
server_url: "{{ gitlab_host }}"
|
server_url: "{{ gitlab_host }}"
|
||||||
validate_certs: false
|
validate_certs: false
|
||||||
|
@ -12,7 +12,7 @@
|
||||||
path: ansible_test_group
|
path: ansible_test_group
|
||||||
state: absent
|
state: absent
|
||||||
|
|
||||||
- name: Create Gitlab Group
|
- name: Create GitLab Group
|
||||||
gitlab_group:
|
gitlab_group:
|
||||||
server_url: "{{ gitlab_host }}"
|
server_url: "{{ gitlab_host }}"
|
||||||
validate_certs: false
|
validate_certs: false
|
||||||
|
@ -28,7 +28,7 @@
|
||||||
- gitlab_group_state is changed
|
- gitlab_group_state is changed
|
||||||
|
|
||||||
|
|
||||||
- name: Create Gitlab Group ( Idempotency test )
|
- name: Create GitLab Group ( Idempotency test )
|
||||||
gitlab_group:
|
gitlab_group:
|
||||||
server_url: "{{ gitlab_host }}"
|
server_url: "{{ gitlab_host }}"
|
||||||
validate_certs: false
|
validate_certs: false
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
name: "{{ gitlab_project_name }}"
|
name: "{{ gitlab_project_name }}"
|
||||||
state: present
|
state: present
|
||||||
|
|
||||||
- name: Cleanup Gitlab hook
|
- name: Cleanup GitLab hook
|
||||||
gitlab_hook:
|
gitlab_hook:
|
||||||
server_url: "{{ gitlab_host }}"
|
server_url: "{{ gitlab_host }}"
|
||||||
validate_certs: false
|
validate_certs: false
|
||||||
|
@ -20,7 +20,7 @@
|
||||||
project: "{{ gitlab_project_name }}"
|
project: "{{ gitlab_project_name }}"
|
||||||
state: absent
|
state: absent
|
||||||
|
|
||||||
- name: Create Gitlab Hook
|
- name: Create GitLab Hook
|
||||||
gitlab_hook:
|
gitlab_hook:
|
||||||
server_url: "{{ gitlab_host }}"
|
server_url: "{{ gitlab_host }}"
|
||||||
validate_certs: false
|
validate_certs: false
|
||||||
|
@ -36,7 +36,7 @@
|
||||||
- gitlab_hook_state is changed
|
- gitlab_hook_state is changed
|
||||||
|
|
||||||
|
|
||||||
- name: Create Gitlab Hook ( Idempotency test )
|
- name: Create GitLab Hook ( Idempotency test )
|
||||||
gitlab_hook:
|
gitlab_hook:
|
||||||
server_url: "{{ gitlab_host }}"
|
server_url: "{{ gitlab_host }}"
|
||||||
validate_certs: false
|
validate_certs: false
|
||||||
|
@ -51,7 +51,7 @@
|
||||||
that:
|
that:
|
||||||
- gitlab_hook_state_again is not changed
|
- gitlab_hook_state_again is not changed
|
||||||
|
|
||||||
- name: Remove Gitlab hook
|
- name: Remove GitLab hook
|
||||||
gitlab_hook:
|
gitlab_hook:
|
||||||
server_url: "{{ gitlab_host }}"
|
server_url: "{{ gitlab_host }}"
|
||||||
validate_certs: false
|
validate_certs: false
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
name: "{{ gitlab_project_name }}"
|
name: "{{ gitlab_project_name }}"
|
||||||
state: present
|
state: present
|
||||||
|
|
||||||
- name: Cleanup Gitlab runner
|
- name: Cleanup GitLab runner
|
||||||
gitlab_runner:
|
gitlab_runner:
|
||||||
server_url: "{{ gitlab_host }}"
|
server_url: "{{ gitlab_host }}"
|
||||||
validate_certs: false
|
validate_certs: false
|
||||||
|
@ -20,7 +20,7 @@
|
||||||
registration_token: "{{ gitlab_runner_registration_token }}"
|
registration_token: "{{ gitlab_runner_registration_token }}"
|
||||||
state: absent
|
state: absent
|
||||||
|
|
||||||
- name: Create Gitlab Runner
|
- name: Create GitLab Runner
|
||||||
gitlab_runner:
|
gitlab_runner:
|
||||||
server_url: "{{ gitlab_host }}"
|
server_url: "{{ gitlab_host }}"
|
||||||
validate_certs: false
|
validate_certs: false
|
||||||
|
@ -37,7 +37,7 @@
|
||||||
|
|
||||||
|
|
||||||
#### COMMENTED AS MODULE WILL UPDATE THE RUNNER IF EXISTS. TO BE DISCUSSED ####
|
#### COMMENTED AS MODULE WILL UPDATE THE RUNNER IF EXISTS. TO BE DISCUSSED ####
|
||||||
# - name: Create Gitlab Runner ( Idempotency test )
|
# - name: Create GitLab Runner ( Idempotency test )
|
||||||
# gitlab_runner:
|
# gitlab_runner:
|
||||||
# server_url: "{{ gitlab_host }}"
|
# server_url: "{{ gitlab_host }}"
|
||||||
# validate_certs: false
|
# validate_certs: false
|
||||||
|
@ -52,7 +52,7 @@
|
||||||
# that:
|
# that:
|
||||||
# - gitlab_runner_state_again is not changed
|
# - gitlab_runner_state_again is not changed
|
||||||
|
|
||||||
- name: Remove Gitlab Runner
|
- name: Remove GitLab Runner
|
||||||
gitlab_runner:
|
gitlab_runner:
|
||||||
server_url: "{{ gitlab_host }}"
|
server_url: "{{ gitlab_host }}"
|
||||||
validate_certs: false
|
validate_certs: false
|
||||||
|
|
|
@ -23,7 +23,7 @@ try:
|
||||||
resp_get_project, resp_find_project_deploy_key,
|
resp_get_project, resp_find_project_deploy_key,
|
||||||
resp_create_project_deploy_key, resp_delete_project_deploy_key)
|
resp_create_project_deploy_key, resp_delete_project_deploy_key)
|
||||||
|
|
||||||
# Gitlab module requirements
|
# GitLab module requirements
|
||||||
if python_version_match_requirement():
|
if python_version_match_requirement():
|
||||||
from gitlab.v4.objects import ProjectKey
|
from gitlab.v4.objects import ProjectKey
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
|
|
@ -23,7 +23,7 @@ try:
|
||||||
resp_get_group, resp_get_missing_group, resp_create_group,
|
resp_get_group, resp_get_missing_group, resp_create_group,
|
||||||
resp_create_subgroup, resp_delete_group, resp_find_group_project)
|
resp_create_subgroup, resp_delete_group, resp_find_group_project)
|
||||||
|
|
||||||
# Gitlab module requirements
|
# GitLab module requirements
|
||||||
if python_version_match_requirement():
|
if python_version_match_requirement():
|
||||||
from gitlab.v4.objects import Group
|
from gitlab.v4.objects import Group
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
|
|
@ -22,7 +22,7 @@ try:
|
||||||
resp_get_project, resp_find_project_hook,
|
resp_get_project, resp_find_project_hook,
|
||||||
resp_create_project_hook, resp_delete_project_hook)
|
resp_create_project_hook, resp_delete_project_hook)
|
||||||
|
|
||||||
# Gitlab module requirements
|
# GitLab module requirements
|
||||||
if python_version_match_requirement():
|
if python_version_match_requirement():
|
||||||
from gitlab.v4.objects import ProjectHook
|
from gitlab.v4.objects import ProjectHook
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
|
|
@ -23,7 +23,7 @@ try:
|
||||||
resp_get_group, resp_get_project_by_name, resp_create_project,
|
resp_get_group, resp_get_project_by_name, resp_create_project,
|
||||||
resp_get_project, resp_delete_project, resp_get_user)
|
resp_get_project, resp_delete_project, resp_get_user)
|
||||||
|
|
||||||
# Gitlab module requirements
|
# GitLab module requirements
|
||||||
if python_version_match_requirement():
|
if python_version_match_requirement():
|
||||||
from gitlab.v4.objects import Project
|
from gitlab.v4.objects import Project
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
|
|
@ -23,7 +23,7 @@ try:
|
||||||
resp_find_runners_list, resp_get_runner,
|
resp_find_runners_list, resp_get_runner,
|
||||||
resp_create_runner, resp_delete_runner)
|
resp_create_runner, resp_delete_runner)
|
||||||
|
|
||||||
# Gitlab module requirements
|
# GitLab module requirements
|
||||||
if python_version_match_requirement():
|
if python_version_match_requirement():
|
||||||
from gitlab.v4.objects import Runner
|
from gitlab.v4.objects import Runner
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
|
|
@ -25,7 +25,7 @@ try:
|
||||||
resp_get_member, resp_get_group, resp_add_member,
|
resp_get_member, resp_get_group, resp_add_member,
|
||||||
resp_update_member, resp_get_member)
|
resp_update_member, resp_get_member)
|
||||||
|
|
||||||
# Gitlab module requirements
|
# GitLab module requirements
|
||||||
if python_version_match_requirement():
|
if python_version_match_requirement():
|
||||||
from gitlab.v4.objects import User
|
from gitlab.v4.objects import User
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
|
Loading…
Reference in a new issue