community.general.gitlab_runner (6.6.8) — module

Create, modify and delete GitLab Runners

Authors: Samy Coenen (@SamyCoenen), Guillaume Martinez (@Lunik)

Install collection

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


Add to requirements.yml

  collections:
    - name: community.general
      version: 6.6.8

Description

Register, update and delete runners with the GitLab API.

All operations are performed using the GitLab API v4.

For details, consult the full API documentation at U(https://docs.gitlab.com/ee/api/runners.html).

A valid private API token is required for all operations. You can create as many tokens as you like using the GitLab web interface at U(https://$GITLAB_URL/profile/personal_access_tokens).

A valid registration token is required for registering a new runner. To create shared runners, you need to ask your administrator to give you this token. It can be found at U(https://$GITLAB_URL/admin/runners/).


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: "Register runner"
  community.general.gitlab_runner:
    api_url: https://gitlab.example.com/
    api_token: "{{ access_token }}"
    registration_token: 4gfdsg345
    description: Docker Machine t1
    state: present
    active: true
    tag_list: ['docker']
    run_untagged: false
    locked: false
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: "Delete runner"
  community.general.gitlab_runner:
    api_url: https://gitlab.example.com/
    api_token: "{{ access_token }}"
    description: Docker Machine t1
    state: absent
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Delete an owned runner as a non-admin
  community.general.gitlab_runner:
    api_url: https://gitlab.example.com/
    api_token: "{{ access_token }}"
    description: Docker Machine t1
    owned: true
    state: absent
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Register runner for a specific project
  community.general.gitlab_runner:
    api_url: https://gitlab.example.com/
    api_token: "{{ access_token }}"
    registration_token: 4gfdsg345
    description: MyProject runner
    state: present
    project: mygroup/mysubgroup/myproject

Inputs

    
group:
    description:
    - ID or full path of the group in the form group/subgroup.
    - Mutually exclusive with I(owned) and I(project).
    type: str
    version_added: 6.5.0
    version_added_collection: community.general

owned:
    default: false
    description:
    - Searches only runners available to the user when searching for existing, when false
      admin token required.
    - Mutually exclusive with I(project) since community.general 4.5.0.
    - Mutually exclusive with I(group).
    type: bool
    version_added: 2.0.0
    version_added_collection: community.general

state:
    choices:
    - present
    - absent
    default: present
    description:
    - Make sure that the runner with the same name exists with the same configuration
      or delete the runner with the same name.
    required: false
    type: str

active:
    default: true
    description:
    - Define if the runners is immediately active after creation.
    required: false
    type: bool

locked:
    default: false
    description:
    - Determines if the runner is locked or not.
    required: false
    type: bool

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

project:
    description:
    - ID or full path of the project in the form of group/name.
    - Mutually exclusive with I(owned) since community.general 4.5.0.
    - Mutually exclusive with I(group).
    type: str
    version_added: 3.7.0
    version_added_collection: community.general

tag_list:
    default: []
    description: The tags that apply to the runner.
    elements: str
    required: false
    type: list

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

description:
    aliases:
    - name
    description:
    - The unique name of the runner.
    required: true
    type: str

access_level:
    choices:
    - not_protected
    - ref_protected
    description:
    - Determines if a runner can pick up jobs only from protected branches.
    - If I(access_level_on_creation) is not explicitly set to C(true), this option is
      ignored on registration and is only applied on updates.
    - If set to C(not_protected), runner can pick up jobs from both protected and unprotected
      branches.
    - If set to C(ref_protected), runner can pick up jobs only from protected branches.
    - The current default is C(ref_protected). This will change to no default in community.general
      8.0.0. From that version on, if this option is not specified explicitly, GitLab
      will use C(not_protected) on creation, and the value set will not be changed on
      any updates.
    required: false
    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

run_untagged:
    default: true
    description:
    - Run untagged jobs or not.
    required: false
    type: bool

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

maximum_timeout:
    default: 3600
    description:
    - The maximum time that a runner has to complete a specific job.
    required: false
    type: int

registration_token:
    description:
    - The registration token is used to register new runners.
    - Required if I(state) is C(present).
    type: str

access_level_on_creation:
    description:
    - Whether the runner should be registered with an access level or not.
    - If set to C(true), the value of I(access_level) is used for runner registration.
    - If set to C(false), GitLab registers the runner with the default access level.
    - The current default of this option is C(false). This default is deprecated and will
      change to C(true) in commuinty.general 7.0.0.
    required: false
    type: bool
    version_added: 6.3.0
    version_added_collection: community.general

Outputs

error:
  description: the error message returned by the GitLab API
  returned: failed
  sample: '400: path is already in use'
  type: str
msg:
  description: Success or failure message
  returned: always
  sample: Success
  type: str
result:
  description: json parsed response from the server
  returned: always
  type: dict
runner:
  description: API object
  returned: always
  type: dict