Compare commits
10 Commits
651b7e7e10
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| b47aeca8fb | |||
|
|
64bc6c60e9 | ||
| e87c8292b1 | |||
| 5481bdae36 | |||
| 9ff01a0f4e | |||
|
|
19d36825c6 | ||
| bc47bd0943 | |||
| af28d1e17d | |||
| 3a726c832f | |||
| 95e4549ae6 |
14
README.md
14
README.md
@@ -16,11 +16,23 @@ Built using Infrastructure as Code (IaC) with [OpenTofu](https://opentofu.org/)
|
|||||||
|
|
||||||
## 🔄 Usage
|
## 🔄 Usage
|
||||||
|
|
||||||
|
### 🛠️ Opentofu
|
||||||
|
|
||||||
1. Checkout repo
|
1. Checkout repo
|
||||||
2. From the opentofu folder, generate `terraform.auto.tfvars` using the supplied ```prepareEnv.sh```
|
2. From the opentofu folder, generate `terraform.auto.tfvars` using the supplied `prepareEnv.sh`
|
||||||
3. Run `tofu init`, `tofu fmt`, `tofu validate`
|
3. Run `tofu init`, `tofu fmt`, `tofu validate`
|
||||||
4. Execute `tofu plan`
|
4. Execute `tofu plan`
|
||||||
5. If successful, run `tofu apply`
|
5. If successful, run `tofu apply`
|
||||||
6. From the ansible folder, run `ansible-playbook main.yml`
|
6. From the ansible folder, run `ansible-playbook main.yml`
|
||||||
|
|
||||||
|
### 🧩 Ansible
|
||||||
|
|
||||||
|
1. Checkout repo
|
||||||
|
2. From the ansible folder, run `export GITEA_RUNNER_TOKEN="{{ YOUR_GITEA_RUNNER_TOKEN }}"`
|
||||||
|
3. Run `ansible-playbook main.yml -e "GITEA_RUNNER_TOKEN=$GITEA_RUNNER_TOKEN"`
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,6 @@
|
|||||||
---
|
---
|
||||||
install_packages:
|
install_packages:
|
||||||
- apt-transport-https
|
|
||||||
- ca-certificates
|
|
||||||
- curl
|
- curl
|
||||||
- gnupg
|
|
||||||
- lsb-release
|
|
||||||
- vim
|
- vim
|
||||||
- git
|
- git
|
||||||
- htop
|
- htop
|
||||||
@@ -12,8 +8,3 @@ install_packages:
|
|||||||
- mc
|
- mc
|
||||||
- net-tools
|
- net-tools
|
||||||
- unattended-upgrades
|
- unattended-upgrades
|
||||||
|
|
||||||
data_folder: /data
|
|
||||||
alpine_latest_image: "alpine:3.22.1@sha256:4bcff63911fcb4448bd4fdacec207030997caf25e9bea4045fa6c8c44de311d1"
|
|
||||||
ubuntu_latest_image: "node:22-trixie@sha256:66fdea746582c4b9678414c13aef9d93839f992e4ea6ffbef7f0785e22312bbd"
|
|
||||||
debian_latest_image: "git.comprofix.com/mmckinnon/debian-latest:2025.08.31-093853"
|
|
||||||
|
|||||||
@@ -20,8 +20,5 @@
|
|||||||
- administrator
|
- administrator
|
||||||
tasks:
|
tasks:
|
||||||
- name: Deploy docker apps
|
- name: Deploy docker apps
|
||||||
include_tasks: "tasks/{{ container }}.yml"
|
import_tasks: "tasks/gitea-runner.yml"
|
||||||
loop:
|
|
||||||
- gitea-runner
|
|
||||||
loop_control:
|
|
||||||
loop_var: container
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
---
|
|
||||||
- name: Create directories for {{ container }}
|
|
||||||
file:
|
|
||||||
path: "{{ data_folder }}/{{ container }}/{{ item }}"
|
|
||||||
state: directory
|
|
||||||
loop: "{{ subfolders | default(['config', 'data', 'logs']) }}"
|
|
||||||
@@ -1,17 +1,20 @@
|
|||||||
- name: Create Folders
|
|
||||||
include_tasks: create_folders.yml
|
- name: Create folders
|
||||||
vars:
|
file:
|
||||||
subfolders:
|
path: "{{ item }}"
|
||||||
- config
|
state: directory
|
||||||
|
with_items:
|
||||||
|
- "/data/gitea-runner"
|
||||||
|
- "/data/gitea-runner/config"
|
||||||
|
|
||||||
- name: Check that config.yaml exists
|
- name: Check that config.yaml exists
|
||||||
stat:
|
stat:
|
||||||
path: "{{ data_folder }}/gitea-runner/config/config.yaml"
|
path: "/data/gitea-runner/config/config.yaml"
|
||||||
register: configyaml
|
register: configyaml
|
||||||
|
|
||||||
- name: Create config.yaml file
|
- name: Create config.yaml file
|
||||||
file:
|
file:
|
||||||
path: "{{ data_folder }}/gitea-runner/config/config.yaml"
|
path: "/data/gitea-runner/config/config.yaml"
|
||||||
state: touch
|
state: touch
|
||||||
mode: "0600"
|
mode: "0600"
|
||||||
access_time: preserve
|
access_time: preserve
|
||||||
@@ -29,12 +32,51 @@
|
|||||||
# - 127.0.0.11
|
# - 127.0.0.11
|
||||||
volumes:
|
volumes:
|
||||||
- "/etc/resolv.conf:/etc/resolv.conf:ro"
|
- "/etc/resolv.conf:/etc/resolv.conf:ro"
|
||||||
|
|
||||||
- /var/run/docker.sock:/var/run/docker.sock
|
- /var/run/docker.sock:/var/run/docker.sock
|
||||||
- "{{ data_folder }}/gitea-runner/config/config.yaml:/config.yaml"
|
- "/data/gitea-runner/config/config.yaml:/config.yaml"
|
||||||
- "/etc/hosts:/etc/hosts:ro"
|
- "/etc/hosts:/etc/hosts:ro"
|
||||||
env:
|
env:
|
||||||
CONFIG_FILE: "/config.yaml"
|
CONFIG_FILE: "/config.yaml"
|
||||||
GITEA_INSTANCE_URL: "https://git.comprofix.com"
|
GITEA_INSTANCE_URL: "https://git.comprofix.com"
|
||||||
GITEA_RUNNER_REGISTRATION_TOKEN: "{{ GITEA_RUNNER_TOKEN }}"
|
GITEA_RUNNER_REGISTRATION_TOKEN: "{{ GITEA_RUNNER_TOKEN }}"
|
||||||
GITEA_RUNNER_NAME: "gtar-runner"
|
GITEA_RUNNER_NAME: "gtar-runner"
|
||||||
GITEA_RUNNER_LABELS: "alpine-latest:docker://{{ alpine_latest_image }},ubuntu-latest:docker://{{ ubuntu_latest_image }},gtar-latest:docker://{{ debian_latest_image }}"
|
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
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
---
|
|
||||||
# Reusable snippet for pulling Docker images
|
|
||||||
|
|
||||||
- name: Set {{ image_name }} image reference
|
|
||||||
set_fact:
|
|
||||||
"{{ image_var }}_image_ref": "{{ image_ref }}"
|
|
||||||
|
|
||||||
- name: Ensure {{ image_name }} image is pulled
|
|
||||||
community.docker.docker_image:
|
|
||||||
name: "{{ image_ref }}"
|
|
||||||
source: pull
|
|
||||||
register: pulled_image
|
|
||||||
|
|
||||||
- name: Save image result under dynamic key
|
|
||||||
set_fact:
|
|
||||||
container_images: >-
|
|
||||||
{{ container_images | default({}) | combine({ image_var: pulled_image }) }}
|
|
||||||
@@ -18,12 +18,12 @@ resource "proxmox_lxc" "gtar" {
|
|||||||
${var.ssh_key}
|
${var.ssh_key}
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
memory = "4096"
|
memory = "8192"
|
||||||
swap = "512"
|
swap = "512"
|
||||||
|
|
||||||
rootfs {
|
rootfs {
|
||||||
storage = "local"
|
storage = "local"
|
||||||
size = "8G"
|
size = "20G"
|
||||||
}
|
}
|
||||||
|
|
||||||
features {
|
features {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ terraform {
|
|||||||
required_providers {
|
required_providers {
|
||||||
proxmox = {
|
proxmox = {
|
||||||
source = "telmate/proxmox"
|
source = "telmate/proxmox"
|
||||||
version = "3.0.2-rc04"
|
version = "3.0.2-rc05"
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,26 +5,11 @@
|
|||||||
":semanticCommitTypeAll(chore)"
|
":semanticCommitTypeAll(chore)"
|
||||||
],
|
],
|
||||||
"ignoreDeps": ["postgres"],
|
"ignoreDeps": ["postgres"],
|
||||||
"regexManagers": [
|
"commitBodyTable": true,
|
||||||
{
|
"ignoreTests": true,
|
||||||
"fileMatch": ["group_vars/all.yml"],
|
"major": {
|
||||||
"matchStrings": ["^(\\s*(?<depName>\\w+_latest_image):\\s*\"?(?<currentValue>[^\"]+)\"?)"],
|
"automerge": false,
|
||||||
"datasourceTemplate": "docker",
|
"commitMessagePrefix": "chore(deps-major): ",
|
||||||
"depNameTemplate": "{{ currentValue }}",
|
"labels": ["dependencies", "breaking"]
|
||||||
"versioningTemplate": "docker"
|
}
|
||||||
}
|
}
|
||||||
],
|
|
||||||
"packageRules": [
|
|
||||||
{
|
|
||||||
"managers": ["docker"],
|
|
||||||
"matchPackageNames": ["alpine", "node"],
|
|
||||||
"pinDigests": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"managers": ["docker"],
|
|
||||||
"matchPackageNames": ["git.comprofix.com/mmckinnon/debian-latest"],
|
|
||||||
"registryUrls": ["https://git.comprofix.com/v2/"],
|
|
||||||
"pinDigests": true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user