community / community.general / 1.3.14 / module / gitlab_project_variable Creates/updates/deletes GitLab Projects Variables Authors: Markus Bergholz (@markuman)community.general.gitlab_project_variable (1.3.14) — module
Install with ansible-galaxy collection install community.general:==1.3.14
collections: - name: community.general version: 1.3.14
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 (I(purge) is C(false)) or will be deleted (I(purge) is C(true)).
- name: Set or update some CI/CD variables community.general.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: Set or update some CI/CD variables community.general.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: value: 3214cbad masked: true protected: true variable_type: env_var
- name: Delete one variable community.general.gitlab_project_variable: api_url: https://gitlab.com api_token: secret_access_token project: markuman/dotfiles state: absent vars: ACCESS_KEY_ID: abc123
vars: default: {} description: - When the list element is a simple key-value pair, masked and protected will be set to false. - When the list element is a dict with the keys I(value), I(masked) and I(protected), the user can have full control about whether a value should be masked, protected or both. - Support for protected values requires GitLab >= 9.3. - Support for masked values requires GitLab >= 11.10. - A I(value) must be a string or a number. - Field I(variable_type) must be a string with either C(env_var), which is the default, or C(file). - When a value is masked, it must be in Base64 and have a length of at least 8 characters. See GitLab documentation on acceptable values for a masked variable (https://docs.gitlab.com/ce/ci/variables/#masked-variables). type: dict purge: default: false description: - When set to true, all variables which are not untouched in the task will be deleted. type: bool state: choices: - present - absent default: present description: - Create or delete project variable. - Possible values are present and absent. type: str api_url: description: - The resolvable endpoint for the API type: str project: description: - The path and name of the project. required: true type: str api_token: description: - GitLab access token with API permissions. required: true type: str api_password: description: - The password to use for authentication against the API type: str api_username: description: - The username to use for authentication against the API type: str validate_certs: default: true description: - Whether or not to validate SSL certs when supplying a https endpoint. type: bool
project_variable: contains: added: description: A list of variables which were created. returned: always sample: '[''ACCESS_KEY_ID'', ''SECRET_ACCESS_KEY'']' type: list removed: description: A list of variables which were deleted. returned: always sample: '[''ACCESS_KEY_ID'', ''SECRET_ACCESS_KEY'']' type: list untouched: description: A list of variables which exist. returned: always sample: '[''ACCESS_KEY_ID'', ''SECRET_ACCESS_KEY'']' type: list updated: description: A list of variables whose values were changed. returned: always sample: '[''ACCESS_KEY_ID'', ''SECRET_ACCESS_KEY'']' type: list description: Four lists of the variablenames which were added, updated, removed or exist. returned: always type: dict