---

- name: Install Gitlab repository
  shell: curl -L https://packages.gitlab.com/install/repositories/runner/gitlab-ci-multi-runner/script.deb.sh | sudo bash

- set_fact:
    gitlab_runner_package_name: "gitlab-ci-multi-runner={{ gitlab_runner_package_version }}"
    gitlab_runner_package_state: "present"
  when: gitlab_runner_package_version is defined

- set_fact:
    gitlab_runner_package_name: "gitlab-ci-multi-runner"
    gitlab_runner_package_state: "latest"
  when: gitlab_runner_package_version is not defined

- name: Install GitLab Runner
  apt:
    name: "{{ gitlab_runner_package_name }}"
    state: "{{ gitlab_runner_package_state }}"
