�
�Udac @` s4 d d l m Z m Z m Z e Z i d d 6d g d 6d d 6Z d Z d Z d
Z d d l
Z
d d l Z d Z
y d d l Z e Z Wn# e k
r� e j � Z
e Z n Xd d l m Z d d
l m Z m Z d d l m Z d d l m Z d e f d � � YZ d � Z d � Z e! d k r0e � n d S( i ( t absolute_importt divisiont print_functions 1.1t metadata_versiont previewt statust communityt supported_bys�
---
module: gitlab_group
short_description: Creates/updates/deletes GitLab Groups
description:
- 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.
version_added: "2.1"
author:
- Werner Dijkerman (@dj-wasabi)
- Guillaume Martinez (@Lunik)
requirements:
- python >= 2.7
- python-gitlab python module <= 1.12.1
extends_documentation_fragment:
- auth_basic
options:
server_url:
description:
- The URL of the GitLab server, with protocol (i.e. http or https).
type: str
login_user:
description:
- GitLab user name.
type: str
login_password:
description:
- GitLab password for login_user
type: str
api_token:
description:
- GitLab token for logging in.
type: str
aliases:
- login_token
name:
description:
- Name of the group you want to create.
required: true
type: str
path:
description:
- The path of the group you want to create, this will be server_url/group_path
- If not supplied, the group_name will be used.
type: str
description:
description:
- A description for the group.
version_added: "2.7"
type: str
state:
description:
- create or delete group.
- Possible values are present and absent.
default: present
type: str
choices: ["present", "absent"]
parent:
description:
- Allow to create subgroups
- Id or Full path of parent group in the form of group/name
version_added: "2.8"
type: str
visibility:
description:
- Default visibility of the group
version_added: "2.8"
choices: ["private", "internal", "public"]
default: private
type: str
s>
- name: "Delete GitLab Group"
gitlab_group:
server_url: https://gitlab.example.com/
api_token: "{{ access_token }}"
validate_certs: False
name: my_first_group
state: absent
- name: "Create GitLab Group"
gitlab_group:
server_url: https://gitlab.example.com/
validate_certs: True
api_username: dj-wasabi
api_password: "MySecretPassword"
name: my_first_group
path: my_first_group
state: present
# The group will by created at https://gitlab.dj-wasabi.local/super_parent/parent/my_first_group
- name: "Create GitLab SubGroup"
gitlab_group:
server_url: https://gitlab.example.com/
validate_certs: True
api_username: dj-wasabi
api_password: "MySecretPassword"
name: my_first_group
path: my_first_group
state: present
parent: "super_parent/parent"
s�
msg:
description: Success or failure message
returned: always
type: str
sample: "Success"
result:
description: json parsed response from the server
returned: always
type: dict
error:
description: the error message returned by the GitLab API
returned: failed
type: str
sample: "400: path is already in use"
group:
description: API object
returned: always
type: dict
N( t basic_auth_argument_spec( t
AnsibleModulet missing_required_lib( t to_native( t findGroupt GitLabGroupc B` sG e Z d � Z d � Z d � Z d � Z d � Z d � Z d � Z RS( c C` s | | _ | | _ d | _ d S( N( t _modulet _gitlabt Nonet groupObject( t selft modulet gitlab_instance( ( sO /usr/lib/python2.7/site-packages/ansible/modules/source_control/gitlab_group.pyt __init__� s c C` s | d k r | j Sd S( N( R t id( R t group( ( sO /usr/lib/python2.7/site-packages/ansible/modules/source_control/gitlab_group.pyt
getGroupId� s c C` s t } | j d k r` | j | � } | j i | d 6| d d 6| d 6| d d 6� } t } n8 | j | j i | d 6| d d 6| d d 6� \ } } | | _ | r| j j r� | j j d t d d | � n y | j
� Wn* t k
r
} | j j d d | � n Xt St Sd S(
Nt namet patht parent_idt
visibilityt descriptiont changedt msgs, Successfully created or updated the group %ss Failed to update group: %s (
t FalseR R R t createGroupt Truet updateGroupR t
check_modet exit_jsont savet Exceptiont fail_json( R R t parentt optionsR R R t e( ( sO /usr/lib/python2.7/site-packages/ansible/modules/source_control/gitlab_group.pyt createOrUpdateGroup� s. c C` sf | j j r t Sy | j j j | � } Wn6 t j j k
ra } | j j d d t
| � � n X| S( NR s Failed to create group: %s ( R R$ R"