riemers / ansible-gitlab-runner Goto Github PK
View Code? Open in Web Editor NEWAnsible role to install gitlab-runner
License: MIT License
Ansible role to install gitlab-runner
License: MIT License
Steps to reproduce:
gitlab-runner unregister --all-runners
)gitlab_runner_docker_volumes: ['/cache']
gitlab_runner_docker_volumes: ['/tmp']
Expected:
/etc/gitlab-runner/config.toml
contains a single runner with a [runners.docker]
entry volumes = ["/tmp"]
Actual:
/etc/gitlab-runner/config.toml
contains a single runner with a [runners.docker]
entry volumes = ["/cache"]
Discussion:
Runner registration is skipped as soon as a runner is found among the registered runners that matches the description of the runner for which the gitlab_runner_docker_volumes
variable was updated. Ideally, registration should be re-run whenever dependent role variables change.
Hello,
First of all thanks for your role and the work you did.
I've a problem when using it. The default config.toml
is not replaced by the new configuration which is generated by Ansible.
When Ansible finish the work, on the server, I've two in the /etc/gitlab-runner
directory.
root@buster:/etc/gitlab-runner# tree
.
├── config.toml
└── config.toml.6155.2019-10-06@07:50:13~
0 directories, 2 files
The first one config.toml
contains the default content of the runner configuration:
concurrent = 2
check_interval = 0
[[runners]]
name = "vagrant"
limit = 1
output_limit = 4096
url = "https://gitlab.com/ci"
token = "..."
executor = "shell"
[runners.docker]
tls_verify = false
disable_cache = false
shm_size = 0
[runners.cache]
environment = []
[[runners]]
name = "vagrant"
limit = 1
output_limit = 4096
url = "https://gitlab.com/ci"
token = "..."
executor = "shell"
[runners.cache]
environment = []
Whereas the second one contains the configuration I want:
concurrent = 2
check_interval = 0
[[runners]]
name = "vagrant"
limit = 1
output_limit = 4096
url = "https://gitlab.com/ci"
token = "..."
executor = "docker"
[runners.docker]
tls_verify = false
image = "alpine:latest"
privileged = true
disable_cache = false
volumes = ["/var/run/docker.sock:/var/run/docker.sock", "/cache"]
shm_size = 0
[runners.cache]
[[runners]]
name = "vagrant"
limit = 1
output_limit = 4096
url = "https://gitlab.com/ci"
token = "..."
executor = "shell"
[runners.cache]
During the process Ansible doesn't display any error.
For information, this my Ansible version information:
ansible 2.8.5
config file = /etc/ansible/ansible.cfg
configured module search path = [u'/home/jdecool/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python2.7/dist-packages/ansible
executable location = /usr/bin/ansible
python version = 2.7.16 (default, Jul 9 2019, 16:43:02) [GCC 8.3.0]
The following vars definition
gitlab_runner_docker_volumes:
- "/cache"
- "/tmp"
results in a registration command like this:
gitlab-runner register ... --docker-volumes "/cache" "/tmp" ...
which does not seem to have the expected result—i.e. only /cache
is being added as a volume in /etc/gitlab-runner/config.toml
instead of both /cache
and /tmp
.
With the following code in place at
it works as expected (both volumes show up inconfig.toml
):
{% for volume in gitlab_runner_docker_volumes | default([]) %}
--docker-volumes "{{ volume }}"
{% endfor %}
$ gitlab-runner --version
Version: 11.1.0
Git revision: 081978aa
Git branch:
GO version: go1.8.7
Built: 2018-07-22T07:24:46+00:00
OS/Arch: linux/amd64
Currently,
what I try to achieve is also to configure predinefed services for some runner. This could be done through runner/configuration/advanced-configuration.html#the-runnersdockerservices-section
So currently I don't know how this could be achieved by using this role.
What I did try but without success was the following:
gitlab_runner_coordinator_url: "https://gitlab.example.com"
gitlab_runner_listen_address: "0.0.0.0:9097"
gitlab_runner_runners:
- name: '{{ ansible_hostname }}'
state: present
executor: docker
docker_image: 'docker:19.03-git'
tags:
- docker
- dind
env_vars: [
"DOCKER_AUTH_CONFIG={\"auths\":{\"docker.example.com\":{\"auth\":\"<my-secret>\"}},\"HttpHeaders\":{\"User-Agent\":\"Docker-client/18.09.5 (linux)\"}}",
"DOCKER_DRIVER=\"overlay2\"",
]
run_untagged: false
# Docker privileged mode
docker_privileged: true
docker_volumes:
- "/cache"
- "/etc/docker/certs.d:/etc/docker/certs.d"
- "/var/lib/docker"
extra_configs:
runners.docker:
wait_for_services_timeout: 15
runners.docker.services:
- name: "docker:19.03-dind"
I hope someone can help me. Thanks in advance.
Fow now only une runner can be registered with this playbook.
However gitlab-runner
allows for any number of runners to be registered on the same machine.
Greetings!
Let's assume I have such configuration for a runner
- name: '{{ ansible_hostname }}-docker'
state: present
executor: 'docker'
output_limit: 4096
concurrent_specific: '0'
run_untagged: true
docker_privileged: false
docker_image: ''
tags: []
locked: 'false'
env_vars: []
and add after tags
parameter
docker_volumes:
- "/var/run/docker.sock:/var/run/docker.sock"
- "/cache"
then configuration will be like that
[[runners]]
name = "localhost-docker"
limit = 0
output_limit = 4096
url = "https://gitlab.infra.local/"
executor = "docker"
volumes = ["/var/run/docker.sock:/var/run/docker.sock", "/cache"]
[runners.custom_build_dir]
[runners.docker]
privileged = false
tls_verify = false
image = ""
disable_entrypoint_overwrite = false
oom_kill_disable = false
disable_cache = false
shm_size = 0
[runners.cache]
[runners.cache.gcs]
environment = []
volumes under runners section, not runners.docker
(.venv) [spigell@hammerhead examples]$ ansible-playbook --version
ansible-playbook 2.9.2
riemers.gitlab-runner - v1.5.4
The dns
and tls_verify
option missing.
Sometimes we should use custom DNS per Job (executor) or mybe we use an internal Docker registry with self signed certificate, so I think its useful to add them.
When re-running a playbook with the gitlab-runner
role, the version of the deployed runner is not updated to the lastest version.
I understand from documentation, that this should be the case. The README says (emphasis added):
gitlab_runner_wanted_version
orgitlab_runner_package_version
- To install a specific version of the gitlab runner (by default it installs the latest). On Mac OSX and Windows, use e.g.gitlab_runner_wanted_version
: 12.4.1. On Linux, usegitlab_runner_package_version
instead.
Are there any caveats? (or is this my user error?)
The runner had been originally deployed with gitlab-runner
1.2.3 and I have tried re-deploying with the same version and the latest 1.6.17.
repo installation script should only run if the repo is missing
this can be achieved in a few ways:
1. Ansible should provide a fact about configured package repositories, run the script conditionally on that fact
2. gather the relevant fact inside this module
3. install repo using Ansible's apt_repository + handle anything else that is in that script
ad 1
such fact doesn't exist at the moment, it's handled by internal logic of apt_repository: https://github.com/ansible/ansible/blob/adc8d607643c3406b88ea9a3b4a9a537f02aa991/lib/ansible/modules/packaging/os/apt_repository.py#L352
ad 2
Probably the quickest and easiest, options:
ad 3
Not really a fan of this approach, the install script/dependencies will evolve in time, so this will introduce constant maintenance overhead. Besides, it feels like redoing somebody else's job.
Resorted to creating my own role since Fedora 30 and 31 do not have an RPM package available.
However this role only checks the distribution but not if the version is actually supported by Gitlab.
List of Operating Systems supported: https://docs.gitlab.com/runner/install/linux-repository.html
I've been using your playbook to install gitlab runner.
My configuration is that the ansible playbook I use is ran against a persistent machine, and not a docker image.
Whenever I make the changes to the playbook, that includes runner config and re-run it, the role ignores existing runner configuration and overwrites it with the new runner config, as a result the old runner stops reporting and I need to re-enter all project-specific settings for that runner in gitlab.
Would it be possible and reasonable to add an option that would make this playbook skip re-registering runner if the runner is already installed and configured on the system? I.e. if config file in /etc/gitlab-runner/config.toml exists, skip registering the runner if skip registration option is enabled.
gitlab-runner
has a built-in support for Prometheus metrics endpoint. In order to enable them, one has to specify listen_address
parameter in the config.toml file
. This, sadly, is currently not supported but this role.
Here's gitlab-runner
documentation for the reference: GitLab Runner monitoring.
Hi,
I have a runner with "docker+machine" as executor, when I execute my playbook it fails on Assemble new config.toml
.
The issue seems to come from the generated config :
name = "my-gitlab-runner"
executor = "docker+machine"
....
[runners.docker+machine]
environment = []
[runners.docker]
...
[runners.machine]
...
My config file done manually:
name = "my-gitlab-runner"
executor = "docker+machine"
....
environment = []
[runners.docker]
...
[runners.machine]
...
My ansible config:
gitlab_runner_runners:
- name: "my-gitlab-runner"
executor: "docker+machine"
docker_image: "alpine"
extra_configs:
runners.machine:
MachineDriver: "digitalocean"
....
Any advice to fix that ?
Do not work on Ubuntu 16.04. Failed, when play:
TASK [riemers.gitlab-runner : Get Gitlab repository installation script] *************************************************************************************************
fatal: [gitlab-runners]: FAILED! => {"msg": "The conditional check 'ansible_os_family == 'Debian'' failed. The error was: error while evaluating conditional (ansible_os_family == 'Debian'): 'ansible_os_family' is undefined\n\nThe error appears to have been in '/Users/user/Git/otus-project/search_engine_infra/ansible/roles/riemers.gitlab-runner/tasks/install-debian.yml': line 3, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: Get Gitlab repository installation script\n ^ here\n"}
Hi. I'm not using the SSH parameters in the gitlab register
task. Basically, the command is running on a dedicated instance for a gitlab runner, so no remote connection. Is there a way to avoid using the SSH parameters? Ideally, the task should use only the parameters that have values.
Hi,
Thank you for this great role. I had a question, and maybe am missing something. It looks like the role supports multiple runners per machine, however, they all go off of the same gitlab registration token. Am I seeing that correctly?
The issue that I'm running into is that I created a token in gitlab for a group and registered my runner just fine, however, gitlab does not allow those runners to be available to subgroups only to the projects in the group. I was wondering if I could setup a second runner with a new registration on the same machine.
If this is not something that is supported right now and you think it is a valuable addition I could try to write up a PR for it.
Thank you
After updating gitlab-runner
from version 1.2.3 to 1.6.17 I see the following error:
FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: 'dict object' has no attribute 'executor'\n\nThe error appears to have been in '/home/fxg/.ansible/roles/riemers.gitlab-runner/tasks/update-config-runner.yml': line 82, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: Set runner executor section\n ^ here\n"}
Explicitly adding the default option shell
has resolved the problem.
gitlab_runner_runners:
- name: '{{ runner_name }}'
tags:
- python3
- host-iron
+ executor: shell
Has this been changed to a mandatory value? From what I see in the failed task, it seems that it should default to shell
anyway.
This is a minor issue, but I was wondering if there was a way to unregister a runner? I set one of my runners to state: absent
, but in my Gitlab CI/CD UI, I still my runner as registered even though it's not running on the my gitlab runner. I assumed that it would be unregistered when I set the state to absent
.
Hi,
Docker volumes a inserted in [[runners]]
section instead of [runners.docker]
Regards,
meta/main.yml
states that all EL versions are supported, but thats not true.
EL8 cannot be supported as there are no gitlab-runner packages available for EL8.
Thanks for providing this role!
Unfortunately, I am getting this error:
TASK [riemers.gitlab-runner : (Debian) Install GitLab Runner] *************************************************************************************************************************************************************************************************
fatal: [78.46.244.166]: FAILED! => {"cache_update_time": 1571013460, "cache_updated": false, "changed": false, "msg": "'/usr/bin/apt-get -y -o \"Dpkg::Options::=--force-confdef\" -o \"Dpkg::Options::=--force-confold\" install 'gitlab-runner'' failed: E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied)\nE: Unable to lock the administration directory (/var/lib/dpkg/), are you root?\n", "rc": 100, "stderr": "E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied)\nE: Unable to lock the administration directory (/var/lib/dpkg/), are you root?\n", "stderr_lines": ["E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied)", "E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?"], "stdout": "", "stdout_lines": []}
To me it looks like you are missing become: true
for the Install GitLab Runner
play in install-debian.yml
(and in install-redhat.yml
too).
Even when I fix this there seem to be more missing become: true
lines in a few places where /etc/gitlab-runner/config.toml
is modified:
Get existing config.toml
in tasks/config-runners.yml
tasks/global-setup.yml
Am I supposed to run the whole role with become: true
? And if yes why are there some become: true
lines in your role then (e.g. in the Install Gitlab repository
play in install-debian.yml
) ?
Hello,
I'm using your role (master branch) for installing my gitlab-runner with docker+machine on gcs.
I ran into the issue that runners.machine already exists in my configuration.
After checking the temp config file i do see a double runners.machine entry:
cat gitlab-runner.1.1kG9jL
name = "gitlab-runner01"
limit = 0
output_limit = 4096
url = "<url>"
environment = []
token = "<token>"
executor = "docker+machine"
[runners.machine]
[runners.machine]
MachineOptions = ["google-project=<id>", "google-machine-type=n1-standard-1", "google-machine-image=https://www.googleapis.com/compute/v1/projects/ubuntu-os-cloud/global/images/family/ubuntu-minimal-1804-lts", "google-tags=gitlab-ci-slave", "google-preemptible=true", "google-zone=europe-west1-d"]
MachineName = "auto-scale-runner-%s"
MachineDriver = "google"
MaxBuilds = 100
IdleTime = 3600
IdleCount = 1
[runners.custom_build_dir]
[runners.cache]
[runners.docker]
image = "ubuntu:latest"
privileged = true
disable_entrypoint_overwrite = false
oom_kill_disable = false
disable_cache = false
volumes = ["/var/run/docker.sock:/var/run/docker.sock", "/cache"]
shm_size = 0
Found following tasks that creates the runners.machine section.
- name: Set runner executor section
lineinfile:
dest: "{{ temp_runner_config.path }}"
regexp: '^\s*\[runners\.{{ gitlab_runner.executor|default("shell") }}\]'
line: ' [runners.{{ gitlab_runner.executor|replace("docker+machine","machine")|default("shell") }}]'
state: "{{ 'absent' if (gitlab_runner.executor|default('shell')) == 'shell' else 'present' }}"
insertafter: '^\s*executor ='
backrefs: no
check_mode: no
notify:
- restart_gitlab_runner
- restart_gitlab_runner_macos
This can be skipped if the executor is docker+machine as you loop over the extra_configs in the vars and insert a second runners.machine.
- name: 'gitlab-runner01'
state: present
# token is an optional override to the global gitlab_runner_registration_token
executor: 'docker+machine'
# Maximum number of jobs to run concurrently on this specific runner.
docker_image: 'ubuntu:latest'
docker_volumes: ["/var/run/docker.sock:/var/run/docker.sock","/cache"]
docker_privileged: true
tags:
- docker
- dind
# Indicates whether this runner can pick jobs without tags.
run_untagged: true
locked: false
extra_configs:
runners.machine:
IdleCount: 1
IdleTime: 3600
MaxBuilds: 100
MachineDriver: 'google'
MachineName: 'auto-scale-runner-%s'
MachineOptions: ["google-project={{ gcloud_project_id }}",
"google-machine-type=n1-standard-1",
"google-machine-image=https://www.googleapis.com/compute/v1/projects/ubuntu-os-cloud/global/images/family/ubuntu-minimal-1804-lts",
"google-tags=gitlab-ci-slave",
"google-preemptible=true",
"google-zone=europe-west1-d"]
After i added the when statement to the task, my problem has been solved and deploy of the runner was successful.
- name: Set runner executor section
lineinfile:
dest: "{{ temp_runner_config.path }}"
regexp: '^\s*\[runners\.{{ gitlab_runner.executor|default("shell") }}\]'
line: ' [runners.{{ gitlab_runner.executor|replace("docker+machine","machine")|default("shell") }}]'
state: "{{ 'absent' if (gitlab_runner.executor|default('shell')) == 'shell' else 'present' }}"
insertafter: '^\s*executor ='
backrefs: no
when: gitlab_runner.executor != "docker+machine"
check_mode: no
notify:
- restart_gitlab_runner
- restart_gitlab_runner_macos
Hello,
I'm running riemers.gitlab-runner 1.6.1 playbook with the following parameters
- role: riemers.gitlab-runner
gitlab_runner_coordinator_url: --skip--
gitlab_runner_registration_token: --skip--
gitlab_runner_package_name: gitlab-runner
gitlab_runner_concurrent: 1
gitlab_runner_runners:
- name: test-run
concurrent_specific: 1
tags: [tr-tag]
run_untagged: false
locked: true
become: true
On initial run everythings seems fine but on subsequent runs I'm getting this failure
RUNNING HANDLER [riemers.gitlab-runner : restart_gitlab_runner] *************************************************************************************************************************************************************************************************************** fatal: [test-playbook]: FAILED! => {"changed": false, "msg": "Could not find the requested service gitlab-runner: host"}
Looks like reload
is not supported by debian gitlab-runner
service.
RUNNING HANDLER [riemers.gitlab-runner : reload_gitlab_runner] ***********************************************************************************************
fatal: [X.X.X.X]: FAILED! => {"changed": false, "msg": "Unable to reload service gitlab-runner: Failed to reload gitlab-runner.service: Job type reload is not applicable for unit gitlab-runner.service.\nSee system logs and 'systemctl status gitlab-runner.service' for details.\n"}
I think restart
can be used instead.
Hi there, I discovered that the role is not compatible with Ansible v2.0+ (< 2.7) anymore as stated in the readme.
This is due to #58 which used the access_time
(and modification_time
) parameters of the file
module introduced in v2.7.
We could either change the code or update the Readme, as you wish @riemers.
Hello,
Thanks for this role. Please, can you import to galaxy the latest releases because the last on Galaxy is v1.1.5.
Have a nice day
Hello,
Just wondering how i can configure a subsection under runners.machine?
The current offpeak option will be removed with gitlabrunner version 14.
The new solution is using the runners.machine.autoscaling option: https://docs.gitlab.com/runner/configuration/autoscale.html#autoscaling-periods-configuration
Current config:
extra_configs:
runners.machine:
IdleCount: 1
IdleTime: 1800
OffPeakPeriods: ["* * 0-7,18-23 * * mon-fri *", "* * * * * sat,sun *"]
OffPeakIdleCount: 0
OffPeakIdleTime: 600
MachineDriver: 'google'
New config:
extra_configs:
runners.machine:
IdleCount: 1
IdleTime: 1800
MachineDriver: 'google'
runners.machine.autoscaling:
Periods: ["* * 0-7,18-23 * * mon-fri *","* * * * * sat,sun *"]
IdleCount: 0
IdleTime: 600
output with the new section:
[runners.machine]
IdleTime = 1800
IdleCount = 1
MachineDriver = "google"
MachineName = "auto-scale-runner-%s"
runners.machine.autoscaling = {"Periods": ["* * 0-7,18-23 * * mon-fri *", "* * * * * sat,sun *"], "IdleCount": 0, "IdleTime": 600}
should be:
[runners.machine]
IdleTime = 1800
IdleCount = 1
MachineDriver = "google"
MachineName = "auto-scale-runner-%s"
[[runners.machine.autoscaling]]
Periods = ["* * 0-7,18-23 * * mon-fri *", "* * * * * sat,sun *"]
IdleCount = 0
IdleTime = 600
Is there an issue with my config in Ansible or is this not supported yet?
Is this useful in your role?
So far i think i need to remove the whole repo and recreate it. But that would also mean the travis/galaxy connections will be lost. Perhaps there is a better way.
p.s. if anyone has a good idea, please tell 👍
Steps to reproduce:
gitlab_runner_docker_privileged: true
/etc/gitlab-runner/config.toml
on host/etc/gitlab-runner/config.toml
on host againExpected:
privileged
is true
privileged
is true
Actual:
privileged
is false
privileged
is true
After updating this role today, an additional runner has been installed which I have not defined.
The vars say:
runner_name: hiccup-notebook
gitlab_runner_runners:
- name: '{{ runner_name }}'
tags:
- python3
- host-iron
executor: shell
The runner hiccup-notebook had previously been installed with gitlab-runner v1.2.3. Today I am trying to update it to the latest version and have subsequently updated gitlab-runner to v1.6.17.
After running the playbook I see in Gitlab are two runners on the same host:
python3
and host-iron
12.10.1 is the old version I am trying to update from.
13.2.1 is the version I want the runner hiccup-notebook to be updated to.
The name of the unexpected runner seems to be automatically picked up from the hostname lxc-gitlab-runner-hiccup-notebook
.
Note that this runner is also missing the tags.
Both runners show up in the log when running the playbook:
TASK [riemers.gitlab-runner : (Windows) Write config section for each runner] *********************************************************************************************************************************************************************************************
skipping: [gitlab-runner-hiccup-notebook] => (item=concurrent = 16
check_interval = 0
[session_server]
session_timeout = 1800
)
skipping: [gitlab-runner-hiccup-notebook] => (item=
name = "hiccup-notebook"
limit = 0
url = "https://gitlab....com/"
environment = []
token = "t0kEn"
executor = "shell"
output_limit = 4096
[runners.custom_build_dir]
[runners.cache]
)
skipping: [gitlab-runner-hiccup-notebook] => (item=
name = "lxc-gitlab-runner-hiccup-notebook-1"
output_limit = 4096
url = "https://gitlab....com/"
token = "t0kEn"
executor = "shell"
[runners.custom_build_dir]
[runners.cache]
[runners.cache.s3]
[runners.cache.gcs]
)
Where does this additional runner come from and how can I avoid it?
Also, how can I make sure the originally installed runner is updated?
It looks to me as if the travis-tests currently do not generated a config.toml
file that includes the configured runners from the test-vars:
TASK [ansible-gitlab-runner : include_tasks] ***********************************
skipping: [localhost] => (item={u'run_untagged': True, u'locked': u'false', u'concurrent_specific': u'0', u'tags': [], u'env_vars': [], u'output_limit': 4096, u'docker_privileged': False, u'state': u'present', u'executor': u'shell', u'docker_image': u'', u'name': u'travis-job-062393db-d09f-40dd-a080-24d8103cafa8'})
I think it is due to the follwing section, where [runner]
-config is only created for runners that where already present in config.toml
.
ansible-gitlab-runner/tasks/config-runner.yml
Lines 18 to 25 in dc5ac7e
Wouldn't it be better to loop over the gitlab-runner-runners
variable without a condition?
vagrant ssh fedora28
# BEFORE RUNNING ANSIBLE ROLE
[vagrant@fedora28 ~]$ sudo dnf repolist
Fedora 28 - x86_64 - Updates 4.0 MB/s | 29 MB 00:07
Fedora 28 - x86_64 4.5 MB/s | 60 MB 00:13
Last metadata expiration check: 0:00:11 ago on Mon 11 Feb 2019 07:14:51 PM UTC.
repo id repo name status
*fedora Fedora 28 - x86_64 57,327
*updates Fedora 28 - x86_64 - Updates 21,147
[vagrant@fedora28 ~]$
# AFTER RUNNING ANSIBLE ROLE
[vagrant@fedora28 ~]$ sudo dnf repolist
Failed to synchronize cache for repo 'runner_gitlab-runner', disabling.
Failed to synchronize cache for repo 'runner_gitlab-runner-source', disabling.
Last metadata expiration check: 0:01:48 ago on Mon 11 Feb 2019 07:14:51 PM UTC.
repo id repo name status
*fedora Fedora 28 - x86_64 57,327
*updates Fedora 28 - x86_64 - Updates 21,147
[vagrant@fedora28 ~]$ cat /etc/yum.repos.d/runner_gitlab-runner.repo
[runner_gitlab-runner]
name=runner_gitlab-runner
baseurl=https://packages.gitlab.com/runner/gitlab-runner/el/28/$basearch
repo_gpgcheck=1
gpgcheck=0
enabled=1
gpgkey=https://packages.gitlab.com/gpg.key
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt
[runner_gitlab-runner-source]
name=runner_gitlab-runner-source
baseurl=https://packages.gitlab.com/runner/gitlab-runner/el/28/SRPMS
repo_gpgcheck=1
gpgcheck=0
enabled=1
gpgkey=https://packages.gitlab.com/gpg.key
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt
[vagrant@fedora28 ~]$ sudo dnf search gitlab-runner
Failed to synchronize cache for repo 'runner_gitlab-runner', disabling.
Failed to synchronize cache for repo 'runner_gitlab-runner-source', disabling.
Last metadata expiration check: 0:08:51 ago on Mon 11 Feb 2019 07:14:51 PM UTC.
No matches found
Ansible Galaxy still has the v1.3.3 showing as the latest available. Seems to me that the reason for that is the commenting out of the notification webhook in the Travis config file:
ansible-gitlab-runner/.travis.yml
Line 35 in b09dc1a
Actually, on your 'master' branch, the role does not correctly register the runner with docker executor.
The parameter --docker-volumes is not correctly set since you try to use a mutli-parameter with comma-separeted.
--docker-volumes use its argument as one parameter. If others parameters needed, we have to set several times --docker-volumes like this:
gitlab-runner register --non-interactive -url https://gitlab.com/ --registration-token xxxxxxx --description test-runner --tag test --executor docker --docker-image debian:stable-backports --docker-volumes "/var/run/docker.sock:/var/run/docker.sock" --docker-volumes "/cache"
In order to have:
[runners.docker]
tls_verify = false
image = "debian:stable-backports"
privileged = false
disable_cache = false
volumes = ["/var/run/docker.sock:/var/run/docker.sock", "/cache"]
shm_size = 0
Instead, actually we've got this:
[runners.docker]
tls_verify = false
image = "debian:stable-backports"
privileged = false
disable_cache = false
volumes = ["[", "/cache"]
shm_size = 0
It seems that the following example playbook from the readme cannot be run:
gitlab_runner_registration_token: 'HUzTMgnxk17YV8Rj8ucQ'
gitlab_runner_runners:
- name: 'Example Docker GitLab Runner'
executor: docker
tags:
- node
- ruby
- mysql
docker_volumes:
- "/var/run/docker.sock:/var/run/docker.sock"
- "/cache"
extra_configs:
runners.docker:
memory: 512m
allowed_images: ["ruby:*", "python:*", "php:*"]
runners.docker.sysctls:
net.ipv4.ip_forward: "1"
As the docker image is not specified and not defined in the default. Extract from defaults:
# The default Docker image to use. Required when executor is `docker`.
docker_image: ''
I get the following error from ansible:
The docker-image needs to be entered
Possible fix is to update the example to:
gitlab_runner_registration_token: 'HUzTMgnxk17YV8Rj8ucQ'
gitlab_runner_runners:
- name: 'Example Docker GitLab Runner'
executor: docker
docker_image: 'alpine'
tags:
- node
- ruby
- mysql
docker_volumes:
- "/var/run/docker.sock:/var/run/docker.sock"
- "/cache"
extra_configs:
runners.docker:
memory: 512m
allowed_images: ["ruby:*", "python:*", "php:*"]
runners.docker.sysctls:
net.ipv4.ip_forward: "1"
The check for the token in tasks/main.yml produces the following error if gitlab_runner_registration_token
is encrypted with ansible vault:
object of type 'AnsibleVaultEncryptedUnicode' has no len()
According to ansible/ansible#33067, it looks like we can just throw a |string
in there to work around it. I'll submit a PR.
local gitlab maybe has certicate problem. set tls_verify = false is useful
Just ran into these errors setting up a new runner:
The error was: 'dict object' has no attribute 'cache_shared'
The error was 'dict_object` has no attribute 'cache_s3_insecure'
I think we need a default or to omit them if they're not defined.
I'm using ansible-gitlab-runner
version 1.2.7 in a playbook. It fails during the assemble
with the following error message:
Near line 29 (last key parsed 'runners'): Key 'runners.docker' has already been defined
This may have the same cause as #45. It looks like one of the loops is called too many times, as two temporary files with the runner configuration are created (1 and 2). I think this happens in the isolate runner configuration
step.
tasks:
- import_role:
name: riemers.gitlab-runner
tags:
- gitlab-runner
vars:
# GitLab runner config
gitlab_runner_package_name: "gitlab-runner"
gitlab_runner_concurrent: 2
gitlab_runner_registration_token: "1234567890"
gitlab_runner_coordinator_url: "https://a.b.c"
gitlab_runner_runners:
- name: "{{ inventory_hostname }}"
executor: docker
docker_image: docker
docker_privileged: "true" # Require for docker in docker
tags:
- mytag
- anothertag
ansible.6j9_YPgitlab-runner-config/
├── gitlab-runner.01.YXMYY1
├── gitlab-runner.02.0GG_Ey
├── gitlab-runner.0.qak3J1
├── gitlab-runner.1.dgnKup
└── gitlab-runner.2.FMi2sx
# cat gitlab-runner.[012].*
concurrent = 2
check_interval = 0
[session_server]
session_timeout = 1800
name = "gitlabrunner0"
url = "https://a.b.c"
token = "1234567890"
executor = "docker"
[runners.docker]
tls_verify = false
image = "docker"
privileged = true
disable_entrypoint_overwrite = false
oom_kill_disable = false
disable_cache = false
shm_size = 0
[runners.cache]
[runners.cache.s3]
[runners.cache.gcs]
name = "gitlabrunner0"
url = "https://a.b.c"
token = "1234567890"
executor = "docker"
[runners.docker]
tls_verify = false
image = "docker"
privileged = true
disable_entrypoint_overwrite = false
oom_kill_disable = false
disable_cache = false
shm_size = 0
[runners.cache]
[runners.cache.s3]
[runners.cache.gcs]
TASK [riemers.gitlab-runner : Get Gitlab repository installation script] *******************************************************************
skipping: [gitlabrunner0]
skipping: [gitlabrunner1]
TASK [riemers.gitlab-runner : Install Gitlab repository] ***********************************************************************************
skipping: [gitlabrunner0]
skipping: [gitlabrunner1]
TASK [riemers.gitlab-runner : set_fact] ****************************************************************************************************
skipping: [gitlabrunner0]
skipping: [gitlabrunner1]
TASK [riemers.gitlab-runner : set_fact] ****************************************************************************************************
skipping: [gitlabrunner0]
skipping: [gitlabrunner1]
TASK [riemers.gitlab-runner : Install GitLab Runner] ***************************************************************************************
skipping: [gitlabrunner0]
skipping: [gitlabrunner1]
TASK [riemers.gitlab-runner : Get Gitlab repository installation script] *******************************************************************
ok: [gitlabrunner1]
ok: [gitlabrunner0]
TASK [riemers.gitlab-runner : Install Gitlab repository] ***********************************************************************************
ok: [gitlabrunner1]
ok: [gitlabrunner0]
TASK [riemers.gitlab-runner : set_fact] ****************************************************************************************************
skipping: [gitlabrunner0]
skipping: [gitlabrunner1]
TASK [riemers.gitlab-runner : set_fact] ****************************************************************************************************
ok: [gitlabrunner0]
ok: [gitlabrunner1]
TASK [riemers.gitlab-runner : Install GitLab Runner] ***************************************************************************************
ok: [gitlabrunner1]
ok: [gitlabrunner0]
TASK [riemers.gitlab-runner : Set concurrent option] ***************************************************************************************
ok: [gitlabrunner1]
ok: [gitlabrunner0]
TASK [riemers.gitlab-runner : Add sentry dsn to config] ************************************************************************************
skipping: [gitlabrunner0]
skipping: [gitlabrunner1]
TASK [riemers.gitlab-runner : List configured runners] *************************************************************************************
ok: [gitlabrunner1]
ok: [gitlabrunner0]
TASK [riemers.gitlab-runner : Register GitLab Runner] **************************************************************************************
included: /home/jostev/devops/gitlab-runner-centos/roles/riemers.gitlab-runner/tasks/register-runner.yml for gitlabrunner1
included: /home/jostev/devops/gitlab-runner-centos/roles/riemers.gitlab-runner/tasks/register-runner.yml for gitlabrunner0
TASK [riemers.gitlab-runner : Register runner to GitLab] ***********************************************************************************
skipping: [gitlabrunner1]
TASK [riemers.gitlab-runner : Register runner to GitLab] ***********************************************************************************
skipping: [gitlabrunner0]
TASK [riemers.gitlab-runner : Get existing config] *****************************************************************************************
ok: [gitlabrunner1]
ok: [gitlabrunner0]
TASK [riemers.gitlab-runner : set_fact] ****************************************************************************************************
ok: [gitlabrunner0]
ok: [gitlabrunner1]
TASK [riemers.gitlab-runner : Create temporary directory] **********************************************************************************
ok: [gitlabrunner1]
ok: [gitlabrunner0]
TASK [riemers.gitlab-runner : include_tasks] ***********************************************************************************************
included: /home/jostev/devops/gitlab-runner-centos/roles/riemers.gitlab-runner/tasks/config-runner.yml for gitlabrunner0, gitlabrunner1
included: /home/jostev/devops/gitlab-runner-centos/roles/riemers.gitlab-runner/tasks/config-runner.yml for gitlabrunner0
included: /home/jostev/devops/gitlab-runner-centos/roles/riemers.gitlab-runner/tasks/config-runner.yml for gitlabrunner0
included: /home/jostev/devops/gitlab-runner-centos/roles/riemers.gitlab-runner/tasks/config-runner.yml for gitlabrunner1
included: /home/jostev/devops/gitlab-runner-centos/roles/riemers.gitlab-runner/tasks/config-runner.yml for gitlabrunner1
TASK [riemers.gitlab-runner : Create temporary file] ***************************************************************************************
ok: [gitlabrunner1]
ok: [gitlabrunner0]
TASK [riemers.gitlab-runner : Isolate runner configuration] ********************************************************************************
ok: [gitlabrunner1]
ok: [gitlabrunner0]
TASK [riemers.gitlab-runner : include_tasks] ***********************************************************************************************
skipping: [gitlabrunner0] => (item={'name': 'gitlabrunner0', 'executor': 'docker', 'docker_image': 'docker', 'docker_privileged': 'true', 'tags': ['docker-builder', 'gitlabrunner']})
skipping: [gitlabrunner1] => (item={'name': 'gitlabrunner1', 'executor': 'docker', 'docker_image': 'docker', 'docker_privileged': 'true', 'tags': ['docker-builder', 'gitlabrunner']})
TASK [riemers.gitlab-runner : Remove runner config] ****************************************************************************************
skipping: [gitlabrunner0] => (item={'name': 'gitlabrunner0', 'executor': 'docker', 'docker_image': 'docker', 'docker_privileged': 'true', 'tags': ['docker-builder', 'gitlabrunner']})
skipping: [gitlabrunner1] => (item={'name': 'gitlabrunner1', 'executor': 'docker', 'docker_image': 'docker', 'docker_privileged': 'true', 'tags': ['docker-builder', 'gitlabrunner']})
TASK [riemers.gitlab-runner : Create temporary file] ***************************************************************************************
ok: [gitlabrunner0]
TASK [riemers.gitlab-runner : Isolate runner configuration] ********************************************************************************
ok: [gitlabrunner0]
TASK [riemers.gitlab-runner : include_tasks] ***********************************************************************************************
included: /home/jostev/devops/gitlab-runner-centos/roles/riemers.gitlab-runner/tasks/update-config-runner.yml for gitlabrunner0
TASK [riemers.gitlab-runner : Create temporary file] ***************************************************************************************
ok: [gitlabrunner0]
TASK [riemers.gitlab-runner : Isolate runner configuration] ********************************************************************************
ok: [gitlabrunner0]
TASK [riemers.gitlab-runner : Set concurrent limit option] *********************************************************************************
ok: [gitlabrunner0]
TASK [riemers.gitlab-runner : Set coordinator URL] *****************************************************************************************
ok: [gitlabrunner0]
TASK [riemers.gitlab-runner : Set runner executor option] **********************************************************************************
ok: [gitlabrunner0]
TASK [riemers.gitlab-runner : Set runner docker image option] ******************************************************************************
ok: [gitlabrunner0]
TASK [riemers.gitlab-runner : Set docker privileged option] ********************************************************************************
ok: [gitlabrunner0]
TASK [riemers.gitlab-runner : Set docker volumes option] ***********************************************************************************
changed: [gitlabrunner0]
TASK [riemers.gitlab-runner : Set cache type option] ***************************************************************************************
ok: [gitlabrunner0]
TASK [riemers.gitlab-runner : Set cache path option] ***************************************************************************************
ok: [gitlabrunner0]
TASK [riemers.gitlab-runner : Set cache s3 server addresss] ********************************************************************************
ok: [gitlabrunner0]
TASK [riemers.gitlab-runner : Set cache s3 access key] *************************************************************************************
ok: [gitlabrunner0]
TASK [riemers.gitlab-runner : Set cache s3 secret key] *************************************************************************************
ok: [gitlabrunner0]
TASK [riemers.gitlab-runner : Set cache shared option] *************************************************************************************
ok: [gitlabrunner0]
TASK [riemers.gitlab-runner : Set cache s3 bucket name option] *****************************************************************************
ok: [gitlabrunner0]
TASK [riemers.gitlab-runner : Set cache s3 bucket location option] *************************************************************************
ok: [gitlabrunner0]
TASK [riemers.gitlab-runner : Set cache s3 insecure option] ********************************************************************************
ok: [gitlabrunner0]
TASK [riemers.gitlab-runner : Set ssh user option] *****************************************************************************************
ok: [gitlabrunner0]
TASK [riemers.gitlab-runner : Set ssh host option] *****************************************************************************************
ok: [gitlabrunner0]
TASK [riemers.gitlab-runner : Set ssh port option] *****************************************************************************************
ok: [gitlabrunner0]
TASK [riemers.gitlab-runner : Set ssh password option] *************************************************************************************
ok: [gitlabrunner0]
TASK [riemers.gitlab-runner : Set ssh identity file option] ********************************************************************************
ok: [gitlabrunner0]
TASK [riemers.gitlab-runner : include] *****************************************************************************************************
skipping: [gitlabrunner0]
TASK [riemers.gitlab-runner : Remove runner config] ****************************************************************************************
skipping: [gitlabrunner0] => (item={'name': 'gitlabrunner0', 'executor': 'docker', 'docker_image': 'docker', 'docker_privileged': 'true', 'tags': ['docker-builder', 'gitlabrunner']})
TASK [riemers.gitlab-runner : Create temporary file] ***************************************************************************************
ok: [gitlabrunner0]
TASK [riemers.gitlab-runner : Isolate runner configuration] ********************************************************************************
ok: [gitlabrunner0]
TASK [riemers.gitlab-runner : include_tasks] ***********************************************************************************************
included: /home/jostev/devops/gitlab-runner-centos/roles/riemers.gitlab-runner/tasks/update-config-runner.yml for gitlabrunner0
TASK [riemers.gitlab-runner : Create temporary file] ***************************************************************************************
ok: [gitlabrunner0]
TASK [riemers.gitlab-runner : Isolate runner configuration] ********************************************************************************
ok: [gitlabrunner0]
TASK [riemers.gitlab-runner : Set concurrent limit option] *********************************************************************************
ok: [gitlabrunner0]
TASK [riemers.gitlab-runner : Set coordinator URL] *****************************************************************************************
ok: [gitlabrunner0]
TASK [riemers.gitlab-runner : Set runner executor option] **********************************************************************************
ok: [gitlabrunner0]
TASK [riemers.gitlab-runner : Set runner docker image option] ******************************************************************************
ok: [gitlabrunner0]
TASK [riemers.gitlab-runner : Set docker privileged option] ********************************************************************************
ok: [gitlabrunner0]
TASK [riemers.gitlab-runner : Set docker volumes option] ***********************************************************************************
changed: [gitlabrunner0]
TASK [riemers.gitlab-runner : Set cache type option] ***************************************************************************************
ok: [gitlabrunner0]
TASK [riemers.gitlab-runner : Set cache path option] ***************************************************************************************
ok: [gitlabrunner0]
TASK [riemers.gitlab-runner : Set cache s3 server addresss] ********************************************************************************
ok: [gitlabrunner0]
TASK [riemers.gitlab-runner : Set cache s3 access key] *************************************************************************************
ok: [gitlabrunner0]
TASK [riemers.gitlab-runner : Set cache s3 secret key] *************************************************************************************
ok: [gitlabrunner0]
TASK [riemers.gitlab-runner : Set cache shared option] *************************************************************************************
ok: [gitlabrunner0]
TASK [riemers.gitlab-runner : Set cache s3 bucket name option] *****************************************************************************
ok: [gitlabrunner0]
TASK [riemers.gitlab-runner : Set cache s3 bucket location option] *************************************************************************
ok: [gitlabrunner0]
TASK [riemers.gitlab-runner : Set cache s3 insecure option] ********************************************************************************
ok: [gitlabrunner0]
TASK [riemers.gitlab-runner : Set ssh user option] *****************************************************************************************
ok: [gitlabrunner0]
TASK [riemers.gitlab-runner : Set ssh host option] *****************************************************************************************
ok: [gitlabrunner0]
TASK [riemers.gitlab-runner : Set ssh port option] *****************************************************************************************
ok: [gitlabrunner0]
TASK [riemers.gitlab-runner : Set ssh password option] *************************************************************************************
ok: [gitlabrunner0]
TASK [riemers.gitlab-runner : Set ssh identity file option] ********************************************************************************
ok: [gitlabrunner0]
TASK [riemers.gitlab-runner : include] *****************************************************************************************************
skipping: [gitlabrunner0]
TASK [riemers.gitlab-runner : Remove runner config] ****************************************************************************************
skipping: [gitlabrunner0] => (item={'name': 'gitlabrunner0', 'executor': 'docker', 'docker_image': 'docker', 'docker_privileged': 'true', 'tags': ['docker-builder', 'gitlabrunner']})
TASK [riemers.gitlab-runner : Create temporary file] ***************************************************************************************
ok: [gitlabrunner1]
TASK [riemers.gitlab-runner : Isolate runner configuration] ********************************************************************************
ok: [gitlabrunner1]
TASK [riemers.gitlab-runner : include_tasks] ***********************************************************************************************
included: /home/jostev/devops/gitlab-runner-centos/roles/riemers.gitlab-runner/tasks/update-config-runner.yml for gitlabrunner1
TASK [riemers.gitlab-runner : Create temporary file] ***************************************************************************************
ok: [gitlabrunner1]
TASK [riemers.gitlab-runner : Isolate runner configuration] ********************************************************************************
ok: [gitlabrunner1]
TASK [riemers.gitlab-runner : Set concurrent limit option] *********************************************************************************
ok: [gitlabrunner1]
TASK [riemers.gitlab-runner : Set coordinator URL] *****************************************************************************************
ok: [gitlabrunner1]
TASK [riemers.gitlab-runner : Set runner executor option] **********************************************************************************
ok: [gitlabrunner1]
TASK [riemers.gitlab-runner : Set runner docker image option] ******************************************************************************
ok: [gitlabrunner1]
TASK [riemers.gitlab-runner : Set docker privileged option] ********************************************************************************
ok: [gitlabrunner1]
TASK [riemers.gitlab-runner : Set docker volumes option] ***********************************************************************************
changed: [gitlabrunner1]
TASK [riemers.gitlab-runner : Set cache type option] ***************************************************************************************
ok: [gitlabrunner1]
TASK [riemers.gitlab-runner : Set cache path option] ***************************************************************************************
ok: [gitlabrunner1]
TASK [riemers.gitlab-runner : Set cache s3 server addresss] ********************************************************************************
ok: [gitlabrunner1]
TASK [riemers.gitlab-runner : Set cache s3 access key] *************************************************************************************
ok: [gitlabrunner1]
TASK [riemers.gitlab-runner : Set cache s3 secret key] *************************************************************************************
ok: [gitlabrunner1]
TASK [riemers.gitlab-runner : Set cache shared option] *************************************************************************************
ok: [gitlabrunner1]
TASK [riemers.gitlab-runner : Set cache s3 bucket name option] *****************************************************************************
ok: [gitlabrunner1]
TASK [riemers.gitlab-runner : Set cache s3 bucket location option] *************************************************************************
ok: [gitlabrunner1]
TASK [riemers.gitlab-runner : Set cache s3 insecure option] ********************************************************************************
ok: [gitlabrunner1]
TASK [riemers.gitlab-runner : Set ssh user option] *****************************************************************************************
ok: [gitlabrunner1]
TASK [riemers.gitlab-runner : Set ssh host option] *****************************************************************************************
ok: [gitlabrunner1]
TASK [riemers.gitlab-runner : Set ssh port option] *****************************************************************************************
ok: [gitlabrunner1]
TASK [riemers.gitlab-runner : Set ssh password option] *************************************************************************************
ok: [gitlabrunner1]
TASK [riemers.gitlab-runner : Set ssh identity file option] ********************************************************************************
ok: [gitlabrunner1]
TASK [riemers.gitlab-runner : include] *****************************************************************************************************
skipping: [gitlabrunner1]
TASK [riemers.gitlab-runner : Remove runner config] ****************************************************************************************
skipping: [gitlabrunner1] => (item={'name': 'gitlabrunner1', 'executor': 'docker', 'docker_image': 'docker', 'docker_privileged': 'true', 'tags': ['docker-builder', 'gitlabrunner']})
TASK [riemers.gitlab-runner : Create temporary file] ***************************************************************************************
ok: [gitlabrunner1]
TASK [riemers.gitlab-runner : Isolate runner configuration] ********************************************************************************
ok: [gitlabrunner1]
TASK [riemers.gitlab-runner : include_tasks] ***********************************************************************************************
included: /home/jostev/devops/gitlab-runner-centos/roles/riemers.gitlab-runner/tasks/update-config-runner.yml for gitlabrunner1
TASK [riemers.gitlab-runner : Create temporary file] ***************************************************************************************
ok: [gitlabrunner1]
TASK [riemers.gitlab-runner : Isolate runner configuration] ********************************************************************************
ok: [gitlabrunner1]
TASK [riemers.gitlab-runner : Set concurrent limit option] *********************************************************************************
ok: [gitlabrunner1]
TASK [riemers.gitlab-runner : Set coordinator URL] *****************************************************************************************
ok: [gitlabrunner1]
TASK [riemers.gitlab-runner : Set runner executor option] **********************************************************************************
ok: [gitlabrunner1]
TASK [riemers.gitlab-runner : Set runner docker image option] ******************************************************************************
ok: [gitlabrunner1]
TASK [riemers.gitlab-runner : Set docker privileged option] ********************************************************************************
ok: [gitlabrunner1]
TASK [riemers.gitlab-runner : Set docker volumes option] ***********************************************************************************
changed: [gitlabrunner1]
TASK [riemers.gitlab-runner : Set cache type option] ***************************************************************************************
ok: [gitlabrunner1]
TASK [riemers.gitlab-runner : Set cache path option] ***************************************************************************************
ok: [gitlabrunner1]
TASK [riemers.gitlab-runner : Set cache s3 server addresss] ********************************************************************************
ok: [gitlabrunner1]
TASK [riemers.gitlab-runner : Set cache s3 access key] *************************************************************************************
ok: [gitlabrunner1]
TASK [riemers.gitlab-runner : Set cache s3 secret key] *************************************************************************************
ok: [gitlabrunner1]
TASK [riemers.gitlab-runner : Set cache shared option] *************************************************************************************
ok: [gitlabrunner1]
TASK [riemers.gitlab-runner : Set cache s3 bucket name option] *****************************************************************************
ok: [gitlabrunner1]
TASK [riemers.gitlab-runner : Set cache s3 bucket location option] *************************************************************************
ok: [gitlabrunner1]
TASK [riemers.gitlab-runner : Set cache s3 insecure option] ********************************************************************************
ok: [gitlabrunner1]
TASK [riemers.gitlab-runner : Set ssh user option] *****************************************************************************************
ok: [gitlabrunner1]
TASK [riemers.gitlab-runner : Set ssh host option] *****************************************************************************************
ok: [gitlabrunner1]
TASK [riemers.gitlab-runner : Set ssh port option] *****************************************************************************************
ok: [gitlabrunner1]
TASK [riemers.gitlab-runner : Set ssh password option] *************************************************************************************
ok: [gitlabrunner1]
TASK [riemers.gitlab-runner : Set ssh identity file option] ********************************************************************************
ok: [gitlabrunner1]
TASK [riemers.gitlab-runner : include] *****************************************************************************************************
skipping: [gitlabrunner1]
TASK [riemers.gitlab-runner : Remove runner config] ****************************************************************************************
skipping: [gitlabrunner1] => (item={'name': 'gitlabrunner1', 'executor': 'docker', 'docker_image': 'docker', 'docker_privileged': 'true', 'tags': ['docker-builder', 'gitlabrunner']})
TASK [riemers.gitlab-runner : copy] ********************************************************************************************************
ok: [gitlabrunner1]
ok: [gitlabrunner0]
TASK [riemers.gitlab-runner : assemble] ****************************************************************************************************
fatal: [gitlabrunner1]: FAILED! => {"changed": false, "msg": "failed to validate: rc:1 error:Runtime platform \u001b[0;m arch\u001b[0;m=amd64 os\u001b[0;m=linux pid\u001b[0;m=5489 revision\u001b[0;m=6946bae7 version\u001b[0;m=12.0.0\nRunning in system-mode. \u001b[0;m \n \u001b[0;m \n\u001b[31;1mFATAL: Near line 29 (last key parsed 'runners'): Key 'runners.docker' has already been defined.\u001b[0;m \n"}
fatal: [gitlabrunner0]: FAILED! => {"changed": false, "msg": "failed to validate: rc:1 error:Runtime platform \u001b[0;m arch\u001b[0;m=amd64 os\u001b[0;m=linux pid\u001b[0;m=18261 revision\u001b[0;m=6946bae7 version\u001b[0;m=12.0.0\nRunning in system-mode. \u001b[0;m \n \u001b[0;m \n\u001b[31;1mFATAL: Near line 29 (last key parsed 'runners'): Key 'runners.docker' has already been defined.\u001b[0;m \n"}
HI!
I try Install gitlab using this playbook using squid in Corporate NetWork.
But dont work
Please add support install using proxy (squid)
Thanks!
file has extra line in the EOF with a single "-" character. this fails ansible-lint as it does not like the empty task
16:55 $ cat roles/riemers.gitlab-runner/tasks/global-setup.yml
---
- name: Set concurrent option
lineinfile:
dest: /etc/gitlab-runner/config.toml
regexp: '^(\s*)concurrent ='
line: '\1concurrent = {{ gitlab_runner_concurrent }}'
state: present
backrefs: yes
notify: restart_gitlab_runner
- name: Add sentry dsn to config
lineinfile:
dest: /etc/gitlab-runner/config.toml
regexp: '^sentry_dsn ='
line: 'sentry_dsn = "{{ gitlab_runner_sentry_dsn }}"'
insertafter: '\s*concurrent.*'
state: present
when: gitlab_runner_sentry_dsn != ""
notify: restart_gitlab_runner
-
16:54 $ ansible-lint site.yml
Traceback (most recent call last):
File "/usr/bin/ansible-lint", line 11, in <module>
load_entry_point('ansible-lint==3.4.20', 'console_scripts', 'ansible-lint')()
File "/usr/lib/python2.7/dist-packages/ansiblelint/__main__.py", line 173, in main
matches.extend(runner.run())
File "/usr/lib/python2.7/dist-packages/ansiblelint/__init__.py", line 229, in run
for child in ansiblelint.utils.find_children(arg, self.playbook_dir):
File "/usr/lib/python2.7/dist-packages/ansiblelint/utils.py", line 158, in find_children
items = _playbook_items(playbook_ds)
File "/usr/lib/python2.7/dist-packages/ansiblelint/utils.py", line 143, in _playbook_items
return [item for play in pb_data for item in play.items()]
AttributeError: 'NoneType' object has no attribute 'items'
Running with config as described in example got an error FATAL: Near line 26 (last key parsed 'runners.docker.sysctls'): bare keys cannot contain '.'
Message:
ASK [riemers.gitlab-runner : Assemble new config.toml] ************************
fatal: [default]: FAILED! => {"changed": false, "msg": "failed to validate: rc:1 error:Runtime platform \u001b[0;m arch\u001b[0;m=amd64 os\u001b[0;m=linux pid\u001b[0;m=12602 revision\u001b[0;m=0e5417a3 version\u001b[0;m=12.0.1\nRunning in system-mode. \u001b[0;m \n \u001b[0;m \n\u001b[31;1mFATAL: Near line 26 (last key parsed 'runners.docker.sysctls'): bare keys cannot contain '.'\u001b[0;m \n"}
This seems to be a mistake as a literal >
character shows up as part of the command being run on the host. I checked by adding -vv
to the ansible-playbook
command.
The following, however, works as I would have expected it to:
- name: Register runner to GitLab
command: >-
gitlab-runner register
--non-interactive
...
My gitlab_runner_runners
look as follows (pretty much like the example):
gitlab_runner_runners:
- name: 'Example Docker GitLab Runner'
executor: docker
docker_image: 'alpine'
tags:
- nginx
- python
docker_volumes:
- "/var/run/docker.sock:/var/run/docker.sock"
- "/cache"
extra_configs:
runners.docker:
memory: 512m
allowed_images: ["nginx:*", "python:*"]
runners.docker.sysctls:
net.ipv4.ip_forward: "1"
When I run the playbook, I keep getting this error:
FATAL: Near line 23 (last key parsed 'runners'): Key 'runners.cache' has already been defined.
Any ideas what I am doing wrong? How can I recover from this? Or is it a bug?
Thanks a lot!
Hi.
Using latest 1.5.2 version, my variables:
gitlab_runner_coordinator_url: https://gitlab.***.ru/
gitlab_runner_registration_token: ***
gitlab_runner_runners:
- name: pbx
run_untagged: false
tags:
- production
- vpbx
When installing, I get such error:
TASK [riemers.gitlab-runner : Copy gitlab-runner-wrapper.sh] *********************************************************************************************************************************************************************************
ok: [5.9.107.164]
TASK [riemers.gitlab-runner : Assemble new config.toml] **************************************************************************************************************************************************************************************
fatal: [5.9.107.164]: FAILED! => {"changed": false, "msg": "failed to validate: rc:1 error:Runtime platform \u001b[0;m arch\u001b[0;m=amd64 os\u001b[0;m=linux pid\u001b[0;m=16399 revision\u001b[0;m=577f813d version\u001b[0;m=12.5.0\nRunning in system-mode. \u001b[0;m \n \u001b[0;m \n\u001b[31;1mFATAL: toml: cannot load TOML value of type map[string]interface {} into a Go string\u001b[0;m \n"}
As I see this task just executes this command:
[root@pbx tmp]# /tmp/gitlab-runner-wrapper.sh /etc/gitlab-runner/config.toml
Runtime platform arch=amd64 os=linux pid=3025 revision=577f813d version=12.5.0
Running in system-mode.
Verifying runner... is alive runner=RszkNp8f
So return value seems to be OK and the runner itself is working OK as I can see. My configuration file config.toml:
[root@pbx tmp]# cat /etc/gitlab-runner/config.toml
concurrent = 8
check_interval = 0
[session_server]
session_timeout = 1800
[[runners]]
name = "pbx"
output_limit = 4096
url = "https://gitlab.***.ru/"
token = "***"
executor = "shell"
[runners.custom_build_dir]
[runners.cache]
[runners.cache.s3]
[runners.cache.gcs]
A can't figure out where is the problem, because everything seems to be OK except the errror... Thanks!
cache_type variable seems to have become mandatory after this 5c9659b
TASK [riemers.gitlab-runner : Set cache s3 section] ******************************************************************************************************* Wednesday 12 February 2020 14:49:14 -0500 (0:00:00.591) 0:01:40.354 **** fatal: [vps3.cloudalbania.com]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: 'dict object' has no attribute 'cache_type'\n\nThe error appears to be in '/home/bzanaj/git/pers/ansible-systems/roles/riemers.gitlab-runner/tasks/update-config-runner.yml': line 128, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: Set cache s3 section\n ^ here\n"}
TASK [debug] *******************************************************************
ok: [focal] => (item=ansible_os_family: Debian) => {
"msg": "ansible_os_family: Debian"
}
ok: [focal] => (item=ansible_distribution: Ubuntu) => {
"msg": "ansible_distribution: Ubuntu"
}
ok: [focal] => (item=ansible_distribution_version: 20.04) => {
"msg": "ansible_distribution_version: 20.04"
}
ok: [focal] => (item=ansible_distribution_release: focal) => {
"msg": "ansible_distribution_release: focal"
}
v1.6.17
Shell provisioner on Ubuntu 20.04 (Focal) suffers the same issue as Debian 10 (Buster) - where lines in .bash_logout prematurely kill the job.
I can confirm that Ubuntu 20.04 has the same offending lines in its default .bash_logout script:
root@focal:/home/gitlab-runner# cat .bash_logout
# ~/.bash_logout: executed by bash(1) when login shell exits.
# when leaving the console clear the screen to increase privacy
if [ "$SHLVL" = 1 ]; then
[ -x /usr/bin/clear_console ] && /usr/bin/clear_console -q
fi
Looks like this role only looks remedies the issue on Debian 10 (Buster) and not Ubuntu 20.04 (Focal).
You can see that only Debian Buster is accounted for in the following two tasks:
(Debian) Install GitLab Runner
(Debian) Remove ~/gitlab-runner/.bash_logout on debian buster
Update the relevant tasks' when
statements to check for Ubuntu 20.04 OR Debian 10.
See https://github.com/riemers/ansible-gitlab-runner/blob/master/tasks/update-config-runner.yml#L195
It says:
line: ' user = {{ gitlab_runner.ssh_user|default("") | to_json }}'
state: "{{ 'present' if gitlab_runner.cache_s3_insecure is defined else 'absent' }}"
Shouldn't it rather be? Why does cache_s3_insecure
have to be defined for the user to be saved?
line: ' user = {{ gitlab_runner.ssh_user|default("") | to_json }}'
state: "{{ 'present' if gitlab_runner.ssh_user is defined else 'absent' }}"
Thank you for this great role. I noticed one thing when I was attempting to run my playbook on a Redhat based machine. It looks as if the register runner task was running every time despite the conditionals. This causes extra runners in the config.toml and in gitlab. I think the issue is in the Unix.yml file for both the List configured runners
and the Check runner is registered
tasks. I believe that a become:yes is needed on both of these.
It seems that we are checking if the runner is already registered but it is looking in the current user's home directory's config.toml which is empty because the role is updating the global one.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.