community.general.gitlab_project module – Creates/updates/deletes GitLab Projects
Note
This module is part of the community.general collection (version 8.6.8).
You might already have this collection installed if you are using the ansible
package.
It is not included in ansible-core
.
To check whether it is installed, run ansible-galaxy collection list
.
To install it, use: ansible-galaxy collection install community.general
.
You need further requirements to be able to use this module,
see Requirements for details.
To use it in a playbook, specify: community.general.gitlab_project
.
Synopsis
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 changes are made to the project, the project will be updated.
Aliases: source_control.gitlab.gitlab_project
Requirements
The below requirements are needed on the host that executes this module.
python-gitlab python module
requests (Python library https://pypi.org/project/requests/)
Parameters
Parameter |
Comments |
---|---|
Allow merge when skipped pipelines exist. Choices:
|
|
GitLab CI job token for logging in. |
|
GitLab OAuth token for logging in. |
|
The password to use for authentication against the API. |
|
GitLab access token with API permissions. |
|
The resolvable endpoint for the API. |
|
The username to use for authentication against the API. |
|
Absolute path image to configure avatar. File size should not exceed 200 kb. This option is only used on creation, not for updates. |
|
Choices:
|
|
The CA certificates bundle to use to verify GitLab server certificate. |
|
Custom path to the CI configuration file for this project. |
|
Choices:
|
|
The default branch name for this project. For project creation, this option requires For project update, the branch must exist. Supports project’s default branch update since community.general 8.0.0. |
|
An description for the project. |
|
Choices:
|
|
Choices:
|
|
Choices:
|
|
Id or the full path of the group of which this projects belongs to. |
|
Git repository which will be imported into gitlab. GitLab server needs read access to this git repository. |
|
Choices:
|
|
Will initialize the project with a default Is only used when the project is created, and ignored otherwise. Choices:
|
|
Whether you want to create issues or not. Possible values are true and false. Choices:
|
|
Enable Git large file systems to manages large files such as audio, video, and graphics files. Choices:
|
|
What requirements are placed upon merges. Possible values are Choices:
|
|
If merge requests can be made or not. Possible values are true and false. Choices:
|
|
Choices:
|
|
The name of the project. |
|
All discussions on a merge request (MR) have to be resolved. Choices:
|
|
Only allow merges if pipeline succeeded. Choices:
|
|
Enable GitLab package repository. Choices:
|
|
The path of the project you want to create, this will be server_url/<group>/path. If not supplied, name will be used. |
|
Choices:
|
|
Remove the source branch after merge. Choices:
|
|
Choices:
|
|
Enable shared runners for this project. Choices:
|
|
If creating snippets should be available or not. Choices:
|
|
Squash commits when merging. Choices:
|
|
Create or delete project. Possible values are present and absent. Choices:
|
|
A topic or list of topics to be assigned to a project. It is compatible with old GitLab server releases (versions before 14, correspond to |
|
Used to create a personal project under a user’s name. |
|
Whether or not to validate SSL certs when supplying a HTTPS endpoint. Choices:
|
|
Choices:
|
|
If an wiki for this project should be available or not. Choices:
|
Attributes
Attribute |
Support |
Description |
---|---|---|
Support: full |
Can run in |
|
Support: none |
Will return details on what has changed (or possibly needs changing in |
Examples
- name: Create GitLab Project
community.general.gitlab_project:
api_url: https://gitlab.example.com/
api_token: "{{ api_token }}"
name: my_first_project
group: "10481470"
- name: Delete GitLab Project
community.general.gitlab_project:
api_url: https://gitlab.example.com/
api_token: "{{ access_token }}"
name: my_first_project
state: absent
delegate_to: localhost
- name: Create GitLab Project in group Ansible
community.general.gitlab_project:
api_url: https://gitlab.example.com/
validate_certs: true
api_username: dj-wasabi
api_password: "MySecretPassword"
name: my_first_project
group: ansible
issues_enabled: false
merge_method: rebase_merge
wiki_enabled: true
snippets_enabled: true
import_url: http://git.example.com/example/lab.git
initialize_with_readme: true
state: present
delegate_to: localhost
- name: get the initial root password
ansible.builtin.shell: |
grep 'Password:' /etc/gitlab/initial_root_password | sed -e 's/Password\: \(.*\)/\1/'
register: initial_root_password
- name: Create a GitLab Project using a username/password via oauth_token
community.general.gitlab_project:
api_url: https://gitlab.example.com/
api_username: root
api_password: "{{ initial_root_password }}"
name: my_second_project
group: "10481470"
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
---|---|
the error message returned by the GitLab API. Returned: failed Sample: |
|
Success or failure message. Returned: always Sample: |
|
API object. Returned: always |
|
json parsed response from the server. Returned: always |