From 2f789b078a0adac91ed602e0852a4f8b02b980ca Mon Sep 17 00:00:00 2001 From: Mark <markvapps@gmail.com> Date: Fri, 1 Dec 2017 16:01:22 +1030 Subject: [PATCH] Remove ssh variable requirement, set docker-volumes correctly for 10.x, add locked variable --- defaults/main.yml | 13 ++++++++++++- handlers/main.yml | 1 + tasks/main.yml | 8 ++++---- tasks/register-runner.yml | 17 ++++++++++------- 4 files changed, 27 insertions(+), 12 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index 5cc044e..6355f21 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -19,4 +19,15 @@ gitlab_runner_docker_image: '' gitlab_runner_tags: [] # Docker privileged mode gitlab_runner_docker_privileged: false - +# Runner SSH user +gitlab_runner_ssh_user: '' +# Runner SSH host +gitlab_runner_ssh_host: '' +# Runner SSH port +gitlab_runner_ssh_port: '' +# Runner SSH password +gitlab_runner_ssh_password: '' +# Runner SSH identity file +gitlab_runner_ssh_identity_file: '' +# Runner Locked +gitlab_runner_locked: 'false' \ No newline at end of file diff --git a/handlers/main.yml b/handlers/main.yml index 84f1e43..efc884c 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -1,3 +1,4 @@ --- - name: restart_gitlab_runner service: name=gitlab-runner state=restarted + become: yes diff --git a/tasks/main.yml b/tasks/main.yml index 6d964db..afd14ac 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,15 +1,15 @@ --- - name: Install GitLab Runner (Debian) - include: install-debian.yml + import_tasks: install-debian.yml when: ansible_os_family == 'Debian' - name: Install GitLab Runner (RedHat) - include: install-redhat.yml + import_tasks: install-redhat.yml when: ansible_os_family == 'RedHat' - name: Set global options - include: global-setup.yml + import_tasks: global-setup.yml - name: Register GitLab Runner - include: register-runner.yml + import_tasks: register-runner.yml when: gitlab_runner_registration_token != '' diff --git a/tasks/register-runner.yml b/tasks/register-runner.yml index cc72280..94cce9c 100644 --- a/tasks/register-runner.yml +++ b/tasks/register-runner.yml @@ -12,11 +12,14 @@ --description '{{ gitlab_runner_description }}' --tag-list '{{ gitlab_runner_tags | join(",") }}' --executor '{{ gitlab_runner_executor }}' + --locked='{{gitlab_runner_locked}}' --docker-image '{{ gitlab_runner_docker_image }}' - --docker-volumes [ "{{ gitlab_runner_docker_volumes | join('", "') }}" ] - --ssh-user '{{gitlab_runner_ssh_user}}' - --ssh-host '{{gitlab_runner_ssh_host}}' - --ssh-port '{{gitlab_runner_ssh_port}}' - --ssh-password '{{gitlab_runner_ssh_password}}' - --ssh-identity-file '{{gitlab_runner_ssh_identity_file}}' - when: configured_runners.stderr.find('\n{{ gitlab_runner_description }}') == -1 + {% if gitlab_runner_docker_volumes is defined %} + --docker-volumes "{{ gitlab_runner_docker_volumes | join('" "') }}" + {% endif %} + --ssh-user '{{ gitlab_runner_ssh_user }}' + --ssh-host '{{ gitlab_runner_ssh_host }}' + --ssh-port '{{ gitlab_runner_ssh_port }}' + --ssh-password '{{ gitlab_runner_ssh_password }}' + --ssh-identity-file '{{ gitlab_runner_ssh_identity_file }}' + when: configured_runners.stderr.find('\n' + gitlab_runner_description) == -1 -- GitLab