community.general.gitlab_runner (3.8.10) — module

Create, modify and delete GitLab Runners.

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

Install collection

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


Add to requirements.yml

  collections:
    - name: community.general
      version: 3.8.10

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: yes
    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

    
owned:
    default: false
    description:
    - Searches only runners available to the user when searching for existing, when false
      admin token required.
    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.
    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:
    - Your private token to interact with the GitLab API.
    type: str

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

access_level:
    choices:
    - ref_protected
    - not_protected
    default: ref_protected
    description:
    - Determines if a runner can pick up jobs only from protected branches.
    - If set to C(ref_protected), runner can pick up jobs only from protected branches.
    - If set to C(not_protected), runner can pick up jobs from both protected and unprotected
      branches.
    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

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

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

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