gitlab_project_variable – Creates/updates/deletes GitLab Projects Variables

New in version 2.9.

Synopsis

  • When a project variable does not exist, it will be created.
  • When a project variable does exist, its value will be updated when the values are different.
  • Variables which are untouched in the playbook, but are not untouched in the GitLab project, they stay untouched (purge is false) or will be deleted (purge is true).

Requirements

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

  • python >= 2.7
  • python-gitlab python module <= 1.12.1

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
project
string / required
The path and name of the project.
purge
boolean
    Choices:
  • no ←
  • yes
When set to true, all variables which are not untouched in the task will be deleted.
state
string
    Choices:
  • present ←
  • absent
Create or delete project variable.
Possible values are present and absent.
validate_certs
boolean
    Choices:
  • no
  • yes ←
Whether or not to validate SSL certs when supplying a https endpoint.
vars
dictionary
Default:
{}
A list of key value pairs.

Examples

- name: Set or update some CI/CD variables
  gitlab_project_variable:
    api_url: https://gitlab.com
    api_token: secret_access_token
    project: markuman/dotfiles
    purge: false
    vars:
      ACCESS_KEY_ID: abc123
      SECRET_ACCESS_KEY: 321cba

- name: Delete one variable
  gitlab_project_variable:
    api_url: https://gitlab.com
    api_token: secret_access_token
    project: markuman/dotfiles
    state: absent
    vars:
      ACCESS_KEY_ID: abc123

Return Values

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

Key Returned Description
project_variable
dictionary
always
Four lists of the variablenames which were added, updated, removed or exist.

 
added
list
always
A list of variables which were created.

Sample:
['ACCESS_KEY_ID', 'SECRET_ACCESS_KEY']
 
removed
list
always
A list of variables which were deleted.

Sample:
['ACCESS_KEY_ID', 'SECRET_ACCESS_KEY']
 
untouched
list
always
A list of variables which exist.

Sample:
['ACCESS_KEY_ID', 'SECRET_ACCESS_KEY']
 
updated
list
always
A list of variables whose values were changed.

Sample:
['ACCESS_KEY_ID', 'SECRET_ACCESS_KEY']


Status

Authors

  • Markus Bergholz (@markuman)

Hint

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