gitlab_user – Creates/updates/deletes Gitlab Users

From Get docs
Ansible/docs/2.8/modules/gitlab user module


gitlab_user – Creates/updates/deletes Gitlab Users

New in version 2.1.


Synopsis

  • 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 changes are made to user, the user will be updated.

Requirements

The below requirements are needed on the host that executes this module.

  • python >= 2.7
  • python-gitlab python module <= 1.12.1
  • administrator rights on the Gitlab server

Parameters

Parameter Choices/Defaults Comments

access_level

string

  • guest

  • reporter
  • developer
  • master
  • maintainer
  • owner

The access level to the group. One of the following can be used.

guest

reporter

developer

master (alias for maintainer)

maintainer

owner

api_password

string

The password to use for authentication against the API

api_token

string

Gitlab token for logging in.


aliases: login_token

api_url

string

The resolvable endpoint for the API

api_username

string

The username to use for authentication against the API

confirm

boolean

added in 2.4

  • no
  • yes

Require confirmation.

email

string / required

The email that belongs to the user.

external

boolean

added in 2.8

  • no

  • yes

Define external parameter for this user

group

string

Id or Full path of parent group in the form of group/name

Add user as an member to this group.

isadmin

boolean

added in 2.8

  • no

  • yes

Grant admin privileges to the user

login_password

string

Gitlab password for login_user

login_user

string

Gitlab user name.

name

string / required

Name of the user you want to create

password

string / required

The password of the user.

GitLab server enforces minimum password length to 8, set this value with 8 or more characters.

server_url

string

The URL of the GitLab server, with protocol (i.e. http or https).

sshkey_file

string

The ssh key itself.

sshkey_name

string

The name of the sshkey

state

string

  • present

  • absent

create or delete group.

Possible values are present and absent.

username

string / required

The username of the user.

validate_certs

boolean

  • no
  • yes

Whether or not to validate SSL certs when supplying a https endpoint.



Examples

- name: "Delete Gitlab User"
  gitlab_user:
    api_url: https://gitlab.example.com/
    api_token: "{{ access_token }}"
    validate_certs: False
    username: myusername
    state: absent
  delegate_to: localhost

- name: "Create Gitlab User"
  gitlab_user:
    api_url: https://gitlab.example.com/
    validate_certs: True
    api_username: dj-wasabi
    api_password: "MySecretPassword"
    name: My Name
    username: myusername
    password: mysecretpassword
    email: [email protected]
    sshkey_name: MySSH
    sshkey_file: ssh-rsa AAAAB3NzaC1yc...
    state: present
    group: super_group/mon_group
    access_level: owner
  delegate_to: localhost

Return Values

Common return values are documented here, the following are the fields unique to this module:

Key Returned Description

error

string

failed

the error message returned by the Gitlab API


Sample:

400: path is already in use

msg

string

always

Success or failure message


Sample:

Success

result

dictionary

always

json parsed response from the server


user

dictionary

always

API object





Status

Authors

  • Werner Dijkerman (@dj-wasabi)
  • Guillaume Martinez (@Lunik)

Hint

If you notice any issues in this documentation you can edit this document to improve it.


© 2012–2018 Michael DeHaan
© 2018–2019 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/2.8/modules/gitlab_user_module.html