1
1
mirror of https://gitlab.archlinux.org/archlinux/infrastructure.git synced 2025-01-18 08:06:16 +01:00
infrastructure/roles/gitlab_runner/tasks/main.yml
Evangelos Foutras dad3061705
gitlab_runner: create /etc/docker directory
This directory isn't part of the docker package so we need to create it.
2023-02-11 16:48:57 +02:00

99 lines
4.3 KiB
YAML

- name: Install dependencies
pacman: name=docker,python-docker,python-gitlab,gitlab-runner state=latest update_cache=yes
notify: Restart gitlab-runner
- name: Install docker.slice
copy: src=docker.slice dest=/etc/systemd/system/ owner=root group=root mode=0644
notify: Systemd daemon-reload
- name: Start docker
systemd: name=docker enabled=yes state=started daemon_reload=yes
- name: Create /etc/docker directory
file: state=directory owner=root group=root mode=0755 path=/etc/docker
- name: Configure Docker daemon for IPv6
copy: src=daemon.json dest=/etc/docker/daemon.json owner=root group=root mode=0644
notify: Restart docker
# We want to give our gitlab-runners full IPv6 capabilities. Sadly, IPv6 and Docker aren't friends. :(
# https://medium.com/@skleeschulte/how-to-enable-ipv6-for-docker-containers-on-ubuntu-18-04-c68394a219a2
# https://github.com/docker/docker.github.io/blob/c0eb65aabe4de94d56bbc20249179f626df5e8c3/engine/userguide/networking/default_network/ipv6.md
# https://github.com/moby/moby/issues/36954
- name: Add IPv6 NAT for docker
ansible.posix.firewalld:
zone: public
permanent: true
state: enabled
immediate: true
rich_rule: rule family="ipv6" destination not address="fd00::1/80" source address="fd00::/80" masquerade
when: configure_firewall
tags:
- firewall
# Please register the runner with this command and save the token as a host var:
# gitlab-runner register \
# --non-interactive \
# --url=https://gitlab.archlinux.org/ \
# --docker-image=archlinux:latest \
# --tag-list=docker \ # Use docker,secure for secure runners and docker,secure-vm for secure VM runners
# --registration-token="{{ vault_gitlab_runner_registration_token }}" \
# --executor=docker \
# --description="{{ inventory_hostname }}" \
# --run-untagged=true \ # Use false for secure runners
# --locked=false \ # Use true for secure runners
# --access-level=not_protected # Use ref_protected for secure runners
# Note: Secure runners must be added manually to the relevant projects
- name: Install runner configuration
template: src=config.toml.j2 dest=/etc/gitlab-runner/config.toml owner=root group=root mode=0600
notify: Restart gitlab-runner
- name: Install gitlab-runner-docker-cleanup.{service,timer}
copy: src={{ item }} dest=/etc/systemd/system/{{ item }} owner=root group=root mode=0644
loop:
- gitlab-runner-docker-cleanup.service
- gitlab-runner-docker-cleanup.timer
notify:
- Restart gitlab-runner-docker-cleanup.timer
- name: Enable and start gitlab-runner-docker-cleanup.timer
systemd: name=gitlab-runner-docker-cleanup.timer state=started enabled=yes daemon_reload=yes
- name: Enable and start gitlab runner service
systemd: name=gitlab-runner state=started enabled=yes daemon_reload=yes
- name: Setup libvirt-executor
when: "'gitlab_vm_runners' in group_names"
block:
- name: Install libvirt-executor-update-base-image dependencies
pacman: name=arch-install-scripts,sequoia-sq state=present
- name: Create libvirt-executor configuration and data directories
file: path={{ item }} state=directory owner=root group=root mode=0755
loop:
- /etc/libvirt-executor
- /usr/local/lib/libvirt-executor
- name: Install libvirt-executor
copy: src={{ item.src }} dest={{ item.dest }} owner=root group=root mode={{ item.mode }}
loop:
- {src: arch-boxes.asc, dest: /usr/local/lib/libvirt-executor/, mode: 644}
- {src: domain_template.xml, dest: /usr/local/lib/libvirt-executor/, mode: 755}
- {src: libvirt-executor, dest: /usr/local/bin/, mode: 755}
- {src: libvirt-executor-update-base-image, dest: /usr/local/bin/, mode: 755}
- name: Create SSH keys for libvirt-executor
command: ssh-keygen -N "" -f /etc/libvirt-executor/id_ed25519 -t ed25519
args:
creates: /etc/libvirt-executor/id_ed25519
- name: Install libvirt-executor-update-base-image.{service,timer}
copy: src={{ item }} dest=/etc/systemd/system/{{ item }} owner=root group=root mode=0644
loop:
- libvirt-executor-update-base-image.service
- libvirt-executor-update-base-image.timer
- name: Enable and start libvirt-executor-update-base-image.timer
systemd: name=libvirt-executor-update-base-image.timer state=started enabled=yes daemon_reload=yes