community.general.gitlab_protected_branch – (un)Marking existing branches for protection

Note

This plugin is part of the community.general collection (version 3.8.1).

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.

To use it in a playbook, specify: community.general.gitlab_protected_branch.

New in version 3.4.0: of community.general

Synopsis

  • (un)Marking existing branches for protection.

Requirements

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

  • python >= 2.7
  • python-gitlab >= 2.3.0

Parameters

Parameter Choices/Defaults Comments
api_password
string
The password to use for authentication against the API
api_token
string / required
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
merge_access_levels
string
    Choices:
  • maintainer
  • developer
  • nobody
Access levels allowed to merge.
name
string / required
The name of the branch that needs to be protected.
Can make use a wildcard charachter for like production/* or just have main or develop as value.
project
string / required
The path and name of the project.
push_access_level
string
    Choices:
  • maintainer
  • developer
  • nobody
Access levels allowed to push.
state
string
    Choices:
  • present
  • absent
Create or delete proteced branch.
validate_certs
boolean
    Choices:
  • no
  • yes
Whether or not to validate SSL certs when supplying a https endpoint.

Examples

- name: Create protected branch on main
  community.general.gitlab_protected_branch:
    api_url: https://gitlab.com
    api_token: secret_access_token
    project: "dj-wasabi/collection.general"
    name: main
    merge_access_levels: maintainer
    push_access_level: nobody

Authors

  • Werner Dijkerman (@dj-wasabi)

© 2012–2018 Michael DeHaan
© 2018–2021 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/latest/collections/community/general/gitlab_protected_branch_module.html