added another bunch of things

This commit is contained in:
Bertrand Lanson 2023-07-27 19:12:18 +02:00
parent 797290d35d
commit b7b340c933
10 changed files with 123 additions and 38 deletions

View File

@ -1,30 +1,23 @@
--- ---
# defaults file for deploy_adguard # defaults file for deploy_adguard
deploy_gitea_runner_directory: /opt/adguard deploy_gitea_runner_directory: /opt/gitea-actions
deploy_gitea_runner_timezone: "Europe/Paris" deploy_gitea_runner_timezone: "Europe/Paris"
deploy_gitea_runner_start_service: false deploy_gitea_runner_start_service: false
deploy_gitea_runner_server_url: https://git.example.com
deploy_gitea_runner_server_token: ""
deploy_gitea_runner_name: gitea-runner
deploy_gitea_runner_config: deploy_gitea_runner_config:
log: log:
level: debug level: debug
runner: runner:
file: .runner file: .runner
capacity: 1 capacity: 1
envs:
env_file: .env
timeout: 3h timeout: 3h
insecure: false insecure: false
fetch_timeout: 5s fetch_timeout: 5s
fetch_interval: 15s fetch_interval: 15s
labels:
- alpine-latest:docker://node:16-alpine
- alpine-3.18:docker://node:16-alpine3.18
- alpine-3.17:docker://node:16-alpine3.17
- alpine-3.16:docker://node:16-alpine3.16
- ubuntu-latest:docker://ghcr.io/catthehacker/ubuntu:act-latest
- ubuntu-22.04:docker://ghcr.io/catthehacker/ubuntu:act-22.04
- ubuntu-20.04:docker://ghcr.io/catthehacker/ubuntu:act-20.04
cache: cache:
enabled: false enabled: true
container: container:
network: "gitea-actions_internal" network: "gitea-actions_internal"
privileged: true privileged: true

View File

@ -1,2 +1,20 @@
--- ---
# handlers file for deploy_gitea_runner # handlers file for deploy_adguard
- name: "Reload systemd file"
ansible.builtin.systemd:
daemon_reload: true
listen: "systemctl-daemon-reload"
- name: "Enable gitea-actions-runnner service"
ansible.builtin.service:
name: gitea-actions-runnner
enabled: true
listen: "systemctl-enable-gitea-actions-runnner"
- name: "Start gitea-actions-runnner service"
ansible.builtin.service:
name: gitea-actions-runnner
state: restarted
listen: "systemctl-restart-gitea-actions-runnner"
throttle: 1
when: deploy_gitea_runner_start_service

View File

@ -4,7 +4,7 @@ galaxy_info:
namespace: 'ednxzu' namespace: 'ednxzu'
role_name: 'deploy_gitea_runner' role_name: 'deploy_gitea_runner'
author: 'Bertrand Lanson' author: 'Bertrand Lanson'
description: '' description: 'Deploy gitea-actions CICD runners using docker-compose on Debian based distributions'
license: 'license (BSD, MIT)' license: 'license (BSD, MIT)'
min_ansible_version: '2.10' min_ansible_version: '2.10'
platforms: platforms:
@ -15,11 +15,12 @@ galaxy_info:
- name: Debian - name: Debian
versions: versions:
- bullseye - bullseye
- bookworm
galaxy_tags: galaxy_tags:
- 'ubuntu' - 'ubuntu'
- 'debian' - 'debian'
- 'adguard' - 'gitea'
- 'adblock' - 'cicd'
- 'docker' - 'docker'
dependencies: [] dependencies: []

35
tasks/configure.yml Normal file
View File

@ -0,0 +1,35 @@
---
# task/configure file for deploy_adguard
- name: "Copy gitea-actions-runnner.service file"
ansible.builtin.template:
src: "gitea-actions-runnner.service.j2"
dest: "/etc/systemd/system/gitea-actions-runnner.service"
owner: root
group: root
mode: '0644'
notify:
- systemctl-daemon-reload
- name: "Configure docker-compose deployment"
block:
- name: "Copy docker-compose.yml template"
ansible.builtin.template:
src: "docker-compose.yml.j2"
dest: "{{ deploy_gitea_runner_directory }}/docker-compose.yml"
owner: root
group: root
mode: '0600'
notify:
- systemctl-enable-gitea-actions-runnner
- systemctl-restart-gitea-actions-runnner
- name: "Copy config.yaml"
ansible.builtin.template:
src: "config.yaml.j2"
dest: "{{ deploy_gitea_runner_directory }}/config.yaml"
owner: root
group: root
mode: '0600'
when: deploy_gitea_runner_config != {}
notify:
- systemctl-restart-gitea-actions-runnner

View File

@ -1,2 +1,7 @@
--- ---
# task/main file for deploy_gitea_runner # task/main file for deploy_gitea_runner
- name: "Import prerequisites.yml"
ansible.builtin.include_tasks: prerequisites.yml
- name: "Import configure.yml"
ansible.builtin.include_tasks: configure.yml

27
tasks/prerequisites.yml Normal file
View File

@ -0,0 +1,27 @@
---
# task/prerequisites file for deploy_gitea_runner
- name: "Create gitea_actions directory"
ansible.builtin.file:
path: "{{ deploy_gitea_runner_directory }}"
state: directory
owner: root
group: root
mode: '0755'
- name: "Create gitea_actions/data directory"
ansible.builtin.file:
path: "{{ deploy_gitea_runner_directory }}/data"
state: directory
owner: root
group: root
mode: '0755'
- name: "Create gitea_actions/cache directory"
ansible.builtin.file:
path: "{{ deploy_gitea_runner_directory }}/cache"
state: directory
owner: root
group: root
mode: '0755'
when: deploy_gitea_runner_config['cache']['enabled'] is defined
and deploy_gitea_runner_config['cache']['enabled']

View File

@ -1,2 +1,2 @@
# {{ ansible_managed }} # {{ ansible_managed }}
{{ deploy_adguard_config | to_yaml }} {{ deploy_gitea_runner_config | to_nice_yaml }}

View File

@ -9,18 +9,22 @@ services:
target: /config.yaml target: /config.yaml
environment: environment:
CONFIG_FILE: /config.yaml CONFIG_FILE: /config.yaml
GITEA_INSTANCE_URL: "https://git.ednz.fr" GITEA_INSTANCE_URL: "{{ deploy_gitea_runner_server_url }}"
GITEA_RUNNER_REGISTRATION_TOKEN: "cWetxKkQT0EpdEkh5K9E7Cq5a7t0RWv5BCUnmuxP" GITEA_RUNNER_REGISTRATION_TOKEN: "{{ deploy_gitea_runner_server_token }}"
GITEA_RUNNER_NAME: "hs1-actions-runner" GITEA_RUNNER_NAME: "{{ deploy_gitea_runner_name }}"
volumes: volumes:
- data:/data - data:/data
{% if deploy_gitea_runner_config['cache']['enabled'] is defined and deploy_gitea_runner_config['cache']['enabled'] %}
- cache:/cache - cache:/cache
{%- endif %}
- /var/run/docker.sock:/var/run/docker.sock - /var/run/docker.sock:/var/run/docker.sock
{% if deploy_gitea_runner_config['cache']['port'] is defined %}
ports: ports:
- target: 1234 - target: {{ deploy_gitea_runner_config['cache']['port'] }}
published: 1234 published: {{ deploy_gitea_runner_config['cache']['port'] }}
protocol: tcp protocol: tcp
mode: ingress mode: ingress
{%- endif %}
networks: networks:
- internal - internal
@ -32,14 +36,16 @@ volumes:
data: data:
driver_opts: driver_opts:
o: bind o: bind
device: /opt/gitea-actions/data device: {{ deploy_gitea_runner_directory }}/data
type: none type: none
{% if deploy_gitea_runner_config['cache']['enabled'] is defined and deploy_gitea_runner_config['cache']['enabled'] %}
cache: cache:
driver_opts: driver_opts:
o: bind o: bind
device: /opt/gitea-actions/cache device: {{ deploy_gitea_runner_directory }}/cache
type: none type: none
{%- endif %}
configs: configs:
config_yaml: config_yaml:
file: /opt/gitea-actions/config.yaml file: {{ deploy_gitea_runner_directory }}/config.yaml

View File

@ -1,13 +0,0 @@
[Unit]
Description=Free and open source, powerful network-wide ads & trackers blocking DNS server.
After=docker.service
Requires=docker.service
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/bin/bash -c "docker-compose -f {{ deploy_adguard_directory }}/docker-compose.yml up --detach"
ExecStop=/bin/bash -c "docker-compose -f {{ deploy_adguard_directory }}/docker-compose.yml down"
[Install]
WantedBy=multi-user.target

View File

@ -0,0 +1,13 @@
[Unit]
Description=Act runner is a runner for Gitea based on Gitea fork of act.
After=docker.service
Requires=docker.service
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/bin/bash -c "docker-compose -f {{ deploy_gitea_runner_directory }}/docker-compose.yml up --detach"
ExecStop=/bin/bash -c "docker-compose -f {{ deploy_gitea_runner_directory }}/docker-compose.yml down"
[Install]
WantedBy=multi-user.target