peay.gitlab-ci-variables
gitlab-ci-variables
This role helps you manage GitLab CI variables using Ansible.
With this role, you can create or update variable values and keep track of existing GitLab CI variables that are not included in your role settings.
Requirements
You need GitLab with v4 API (GitLab version 9.0 or newer).
Installation
To install, run:
ansible-galaxy install peay.gitlab-ci-variables
Usage
You can find variable details in defaults/main.yml.
You need to provide the API URL and token like this:
# API token for GitLab
gitlab_token: "XXXXXXXXXXXXXXXXXXXX"
# API URL for GitLab
gitlab_api_url: https://some-url-to-gitlab.com/api/v4
You can manage GitLab CI variables for each project. Here’s an example managing variables for two projects:
# Variables to manage for each GitLab project
gitlab_ci_variables:
- name: "group/project"
kind: "project"
variables:
- key: VARIABLE_1
value: value
- name: "group/project2"
kind: "project"
variables:
- key: VARIABLE_1
value: value
- key: VARIABLE_2
value: value
- name: "group"
kind: "group"
variables:
- key: VARIABLE_3
value: value
- key: VARIABLE_4
value: value
By default, the role also checks for any unknown GitLab CI variables (not listed in gitlab_ci_variables
). You can turn off this check by setting:
# If enabled, check for unknown variables in GitLab
# that are not managed by this role
gitlab_ci_check_unknown: false
This check will not delete any existing unknown variables.