community.general.gitlab_instance_variable (8.5.0) — module

Creates, updates, or deletes GitLab instance variables

| "added in version" 7.1.0 of community.general"

Authors: Benedikt Braunger (@benibr)

Install collection

Install with ansible-galaxy collection install community.general:==8.5.0


Add to requirements.yml

  collections:
    - name: community.general
      version: 8.5.0

Description

Creates a instance variable if it does not exist.

When a instance variable does exist, its value will be updated if the values are different.

Support for instance variables requires GitLab >= 13.0.

Variables which are not mentioned in the modules options, but are present on the GitLab instance, will either stay (O(purge=false)) or will be deleted (O(purge=true)).


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Set or update some CI/CD variables
  community.general.gitlab_instance_variable:
    api_url: https://gitlab.com
    api_token: secret_access_token
    purge: false
    variables:
      - name: ACCESS_KEY_ID
        value: abc1312cba
      - name: SECRET_ACCESS_KEY
        value: 1337
        masked: true
        protected: true
        variable_type: env_var
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Delete one variable
  community.general.gitlab_instance_variable:
    api_url: https://gitlab.com
    api_token: secret_access_token
    state: absent
    variables:
      - name: ACCESS_KEY_ID

Inputs

    
purge:
    default: false
    description:
    - When set to V(true), delete all variables which are not mentioned in the task.
    type: bool

state:
    choices:
    - present
    - absent
    default: present
    description:
    - Create or delete instance variable.
    type: str

api_url:
    description:
    - The resolvable endpoint for the API.
    type: str

ca_path:
    description:
    - The CA certificates bundle to use to verify GitLab server certificate.
    type: str
    version_added: 8.1.0
    version_added_collection: community.general

api_token:
    description:
    - GitLab access token with API permissions.
    type: str

variables:
    default: []
    description:
    - A list of dictionaries that represents CI/CD variables.
    elements: dict
    suboptions:
      masked:
        default: false
        description:
        - Whether variable value is masked or not.
        type: bool
      name:
        description:
        - The name of the variable.
        required: true
        type: str
      protected:
        default: false
        description:
        - Whether variable value is protected or not.
        type: bool
      value:
        description:
        - The variable value.
        - Required when O(state=present).
        type: str
      variable_type:
        choices:
        - env_var
        - file
        default: env_var
        description:
        - Whether a variable is an environment variable (V(env_var)) or a file (V(file)).
        type: str
    type: list

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

api_job_token:
    description:
    - GitLab CI job token for logging in.
    type: str
    version_added: 4.2.0
    version_added_collection: community.general

validate_certs:
    default: true
    description:
    - Whether or not to validate SSL certs when supplying a HTTPS endpoint.
    type: bool

api_oauth_token:
    description:
    - GitLab OAuth token for logging in.
    type: str
    version_added: 4.2.0
    version_added_collection: community.general

Outputs

instance_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 pre-existing variables whose values have been set.
      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