community.general.gitlab_project_approvals module – Manage project-level merge request approvals settings on GitLab Server

Note

This module is part of the community.general collection (version 13.1.0).

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_approvals.

New in community.general 13.1.0

Synopsis

  • This module allows to manage project-level merge request approval configurations.

Requirements

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

Parameters

Parameter

Comments

api_job_token

string

added in community.general 4.2.0

GitLab CI job token for logging in.

api_oauth_token

string

added in community.general 4.2.0

GitLab OAuth token for logging in.

api_password

string

The password to use for authentication against the API.

api_token

string

GitLab access token with API permissions.

api_url

string

The resolvable endpoint for the API.

api_username

string

The username to use for authentication against the API.

approvals_before_merge

integer

The number of approvals required before a merge request can be merged.

Deprecated in GitLab 12.3.

ca_path

string

added in community.general 8.1.0

The CA certificates bundle to use to verify GitLab server certificate.

disable_overriding_approvers_per_merge_request

boolean

Disable overriding approvers per merge request.

Choices:

  • false

  • true

merge_requests_author_approval

boolean

Allow authors to self-approve merge requests.

Choices:

  • false

  • true

merge_requests_disable_committers_approval

boolean

Prevent committers from approving merge requests.

Choices:

  • false

  • true

project

string / required

The name or full path of the GitLab project.

require_password_to_approve

boolean

Require password reauthentication to approve a merge request.

Deprecated in GitLab 16.9.

Choices:

  • false

  • true

require_reauthentication_to_approve

boolean

Require user reauthentication to approve a merge request.

Choices:

  • false

  • true

reset_approvals_on_push

boolean

Reset approvals on new commit.

Choices:

  • false

  • true

selective_code_owner_removals

boolean

Reset approvals from Code Owners if their files are changed.

Choices:

  • false

  • true

validate_certs

boolean

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

Choices:

  • false

  • true ← (default)

Attributes

Attribute

Support

Description

check_mode

Support: full

Can run in check_mode and return changed status prediction without modifying target.

diff_mode

Support: none

Returns details on what has changed (or possibly needs changing in check_mode), when in diff mode.

Examples

- name: Configure GitLab Project approval settings
  community.general.gitlab_project_approvals:
    api_url: https://gitlab.example.com/
    api_token: "{{ api_token }}"
    project: my_group/my_project
    reset_approvals_on_push: true
    merge_requests_author_approval: false
    merge_requests_disable_committers_approval: true

Return Values

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

Key

Description

project_approvals

dictionary

The updated GitLab project approval settings.

Returned: always

Sample: {"approvals_before_merge": 2, "disable_overriding_approvers_per_merge_request": false, "merge_requests_author_approval": false, "merge_requests_disable_committers_approval": true, "reset_approvals_on_push": true}

Authors

  • Masaru Onodera (@masa-orca)