refacto gitlab-runner
This commit is contained in:
parent
ad2eb3d40b
commit
2f01747638
@ -1,19 +1,24 @@
|
||||
---
|
||||
- name: 'gitlab-runner: create docker volume'
|
||||
- name: gitlab-runner | check vars are defined
|
||||
assert:
|
||||
that:
|
||||
- gitlab_domain is defined
|
||||
tags: ['docker_gitlab-runner']
|
||||
|
||||
- include_tasks: base.yml
|
||||
tags: ['docker_gitlab']
|
||||
|
||||
- name: 'gitlab-runner | create docker volumes'
|
||||
docker_volume:
|
||||
name: '{{ item }}'
|
||||
with_items:
|
||||
- gitlab-runner-dind__var_lib_docker
|
||||
- gitlab-runner-dind__certs
|
||||
- gitlab-runner__home_gitlab-runner
|
||||
- gitlab-runner__etc_gitlab-runner
|
||||
tags: ['docker_gitlab-runner']
|
||||
|
||||
- name: 'gitlab-runner: create docker volume gitlab-runner_etc_gitlab-runner'
|
||||
docker_volume:
|
||||
name: gitlab-runner__etc_gitlab-runner
|
||||
register: register_gitlab_runner_etc_gitlab_runner
|
||||
tags: ['docker_gitlab-runner']
|
||||
|
||||
- name: 'gitlab-runner: register to gitlab'
|
||||
- name: 'gitlab-runner | register to gitlab'
|
||||
uri:
|
||||
url: 'https://{{ gitlab_runner_runner_url }}/api/v4/runners'
|
||||
method: POST
|
||||
@ -27,7 +32,7 @@
|
||||
- 'gitlab_runner_register_token is defined'
|
||||
tags: ['docker_gitlab-runner']
|
||||
|
||||
- name: 'gitlab-runner: configure config.toml'
|
||||
- name: 'gitlab-runner | configure config.toml'
|
||||
copy:
|
||||
dest: '{{ register_gitlab_runner_etc_gitlab_runner.ansible_facts.docker_volume.Mountpoint }}/config.toml'
|
||||
mode: '0600'
|
||||
@ -59,47 +64,7 @@
|
||||
- 'register_gitlab_runner_register.json.token is defined'
|
||||
tags: ['docker_gitlab-runner']
|
||||
|
||||
# use gitlab runner with docker executors and isolation in dind ;)
|
||||
- name: 'gitlab-runner: deploy container docker'
|
||||
docker_container:
|
||||
name: docker
|
||||
image: docker:{{ gitlab_runner_dind_version }}
|
||||
privileged: yes
|
||||
volumes:
|
||||
- 'gitlab-runner-dind__var_lib_docker:/var/lib/docker'
|
||||
- 'gitlab-runner-dind__certs:/certs'
|
||||
log_driver: syslog
|
||||
log_options:
|
||||
tag: docker_gitlab-runner
|
||||
restart_policy: 'unless-stopped'
|
||||
pull: '{{ docker_pull }}'
|
||||
tags: ['docker_gitlab-runner']
|
||||
|
||||
- name: 'gitlab-runner: deploy container'
|
||||
docker_container:
|
||||
name: gitlab-runner
|
||||
hostname: '{{ inventory_hostname }}'
|
||||
image: gitlab/gitlab-runner:{{ gitlab_runner_version }}
|
||||
links:
|
||||
- docker:gitlab-runner
|
||||
env:
|
||||
DOCKER_HOST: tcp://docker:2376/
|
||||
DOCKER_TLS_CERTDIR: "/certs"
|
||||
DOCKER_DRIVER: overlay2
|
||||
volumes:
|
||||
- 'gitlab-runner__etc_gitlab-runner:/etc/gitlab-runner'
|
||||
- 'gitlab-runner__home_gitlab-runner:/home/gitlab-runner'
|
||||
- 'gitlab-runner-dind__certs:/certs'
|
||||
log_driver: syslog
|
||||
log_options:
|
||||
tag: docker_gitlab
|
||||
restart_policy: 'unless-stopped'
|
||||
pull: '{{ docker_pull }}'
|
||||
register: register_docker_container_gitlab_runner
|
||||
tags: ['docker_gitlab-runner']
|
||||
|
||||
|
||||
- name: 'gitab-runner: configure cron garbage in dind'
|
||||
- name: 'gitab-runner | configure cron garbage in dind'
|
||||
cron:
|
||||
name: "gitlab_runner_garbage"
|
||||
minute: "50"
|
||||
@ -107,7 +72,7 @@
|
||||
job: "/usr/bin/docker exec docker docker system prune -f; /usr/bin/docker exec docker docker volume prune -f 2>&1 |logger -t gitlab-runner"
|
||||
tags: ['docker_gitlab-runner']
|
||||
|
||||
- name: 'gitab-runner: purge dind cache'
|
||||
- name: 'gitab-runner | purge dind cache'
|
||||
cron:
|
||||
name: "purge_dind_ci_cache"
|
||||
minute: "30"
|
||||
|
52
templates/compose/gitlab-runner.yml.j2
Normal file
52
templates/compose/gitlab-runner.yml.j2
Normal file
@ -0,0 +1,52 @@
|
||||
version: '3.7'
|
||||
|
||||
networks:
|
||||
gitlab-runner:
|
||||
external: true
|
||||
|
||||
volumes:
|
||||
gitlab-runner-dind__var_lib_docker:
|
||||
external: true
|
||||
gitlab-runner-dind__certs:
|
||||
external: true
|
||||
gitlab-runner__home_gitlab-runner:
|
||||
external: true
|
||||
gitlab-runner__etc_gitlab-runner:
|
||||
external: true
|
||||
|
||||
services:
|
||||
gitlab-runner:
|
||||
image: gitlab/gitlab-runner:{{ gitlab_runner_version | default("latest") }}
|
||||
container_name: gitlab-runner
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
DOCKER_HOST: tcp://docker:2376/
|
||||
DOCKER_TLS_CERTDIR: "/certs"
|
||||
DOCKER_DRIVER: overlay2
|
||||
volumes:
|
||||
- gitlab-runner__etc_gitlab-runner:/etc/gitlab-runner
|
||||
- gitlab-runner__home_gitlab-runner:/home/gitlab-runner
|
||||
- gitlab-runner-dind__certs:/certs
|
||||
networks:
|
||||
- gitlab-runner
|
||||
links:
|
||||
- docker:gitlab-runner
|
||||
logging:
|
||||
driver: syslog
|
||||
options:
|
||||
tag: docker_gitlab-runner
|
||||
|
||||
docker:
|
||||
image: {{ gitlab_runner_dind_version | default("latest") }}
|
||||
container_name: docker
|
||||
restart: unless-stopped
|
||||
privileged: yes
|
||||
volumes:
|
||||
- gitlab-runner-dind__var_lib_docker:/var/lib/docker
|
||||
- gitlab-runner-dind__certs:/certs
|
||||
networks:
|
||||
- gitlab-runner
|
||||
logging:
|
||||
driver: syslog
|
||||
options:
|
||||
tag: docker_gitlab-runner
|
Loading…
x
Reference in New Issue
Block a user