82 lines
2.3 KiB
YAML
82 lines
2.3 KiB
YAML
|
|
- name: Create folders
|
|
file:
|
|
path: "{{ item }}"
|
|
state: directory
|
|
with_items:
|
|
- "/data/gitea-runner"
|
|
- "/data/gitea-runner/config"
|
|
|
|
- name: Check that config.yaml exists
|
|
stat:
|
|
path: "/data/gitea-runner/config/config.yaml"
|
|
register: configyaml
|
|
|
|
- name: Create config.yaml file
|
|
file:
|
|
path: "/data/gitea-runner/config/config.yaml"
|
|
state: touch
|
|
mode: "0600"
|
|
access_time: preserve
|
|
modification_time: preserve
|
|
when: configyaml.stat.exists == False
|
|
|
|
- name: Create the gitea-runner container
|
|
docker_container:
|
|
name: gitea-runner
|
|
image: gitea/act_runner:0.2.13
|
|
restart_policy: unless-stopped
|
|
recreate: true
|
|
# dns_servers:
|
|
# - 10.10.10.1
|
|
# - 127.0.0.11
|
|
volumes:
|
|
- "/etc/resolv.conf:/etc/resolv.conf:ro"
|
|
|
|
- /var/run/docker.sock:/var/run/docker.sock
|
|
- "/data/gitea-runner/config/config.yaml:/config.yaml"
|
|
- "/etc/hosts:/etc/hosts:ro"
|
|
env:
|
|
CONFIG_FILE: "/config.yaml"
|
|
GITEA_INSTANCE_URL: "https://git.comprofix.com"
|
|
GITEA_RUNNER_REGISTRATION_TOKEN: "{{ GITEA_RUNNER_TOKEN }}"
|
|
GITEA_RUNNER_NAME: "gtar-runner"
|
|
GITEA_RUNNER_LABELS: "alpine-latest:docker://git.comprofix.com/mmckinnon/alpine-runner:latest,ubuntu-latest:docker://node:22-trixie,homelab-latest:docker://git.comprofix.com/mmckinnon/debian-latest:latest"
|
|
|
|
- name: Create pull-ci-images.sh script
|
|
copy:
|
|
dest: /usr/local/bin/pull-ci-images.sh
|
|
mode: '0755'
|
|
owner: root
|
|
group: root
|
|
content: |
|
|
#!/bin/bash
|
|
set -euo pipefail
|
|
|
|
IMAGES=(
|
|
"ghcr.io/renovatebot/renovate:latest"
|
|
"git.comprofix.com/mmckinnon/alpine-runner:latest"
|
|
"git.comprofix.com/mmckinnon/debian-latest:latest"
|
|
"node:22-trixie"
|
|
"catthehacker/ubuntu:act-latest"
|
|
)
|
|
|
|
echo "Starting image pull at $(date)"
|
|
|
|
for image in "${IMAGES[@]}"; do
|
|
echo "Pulling $image..."
|
|
docker pull "$image"
|
|
done
|
|
|
|
echo "Pruning old images..."
|
|
docker image prune -af --filter "until=168h"
|
|
|
|
echo "Image pull completed at $(date)"
|
|
|
|
- name: Ensure cron job for pulling CI images exists
|
|
cron:
|
|
name: "Pull latest CI images daily"
|
|
user: "{{ ansible_user_id }}"
|
|
job: "/usr/local/bin/pull-ci-images.sh >> /var/log/pull-ci-images.log 2>&1"
|
|
hour: 2
|
|
minute: 0 |