From 47d6aceca299896c6f6f8c368006273388ceb329 Mon Sep 17 00:00:00 2001 From: Matthew McKinnon Date: Thu, 2 Oct 2025 19:57:57 +1000 Subject: [PATCH] Initial Commit --- ansible/ghshr.yml | 24 --------------- ansible/group_vars/all.yml | 4 ++- ansible/inventory/hosts.ini | 4 +-- ansible/main.yml | 29 +++++++++++++++++- ansible/requirements.yml | 4 +++ ansible/tasks/create_folders.yml | 6 ++++ ansible/tasks/gitea-runner.yml | 40 +++++++++++++++++++++++++ opentofu/{200-github.tf => 200-gtar.tf} | 7 +++-- opentofu/provider.tf | 8 ++--- 9 files changed, 91 insertions(+), 35 deletions(-) delete mode 100644 ansible/ghshr.yml create mode 100644 ansible/requirements.yml create mode 100644 ansible/tasks/create_folders.yml create mode 100644 ansible/tasks/gitea-runner.yml rename opentofu/{200-github.tf => 200-gtar.tf} (85%) diff --git a/ansible/ghshr.yml b/ansible/ghshr.yml deleted file mode 100644 index 9aa899d..0000000 --- a/ansible/ghshr.yml +++ /dev/null @@ -1,24 +0,0 @@ ---- -- name: Prepare all servers - hosts: all - become: true - - pre_tasks: - - name: Setup base system - import_tasks: tasks/base.yml - tags: base_setup - - tasks: - - name: Create ghshr folders - file: - path: "/opt/actions-runner" - state: directory - - - name: Download ans extract the GitHub Actions Runner - ansible.builtin.unarchive: - src: https://github.com/actions/runner/releases/download/v2.328.0/actions-runner-linux-x64-2.328.0.tar.gz - dest: /opt/actions-runner - remote_src: yes - - - \ No newline at end of file diff --git a/ansible/group_vars/all.yml b/ansible/group_vars/all.yml index 35f9a0b..14d2229 100644 --- a/ansible/group_vars/all.yml +++ b/ansible/group_vars/all.yml @@ -11,4 +11,6 @@ install_packages: - jq - mc - net-tools - - unattended-upgrades \ No newline at end of file + - unattended-upgrades + +data_folder: /data \ No newline at end of file diff --git a/ansible/inventory/hosts.ini b/ansible/inventory/hosts.ini index 435753c..c0c60b5 100644 --- a/ansible/inventory/hosts.ini +++ b/ansible/inventory/hosts.ini @@ -1,3 +1,3 @@ -[ghshr] -ghshr.comprofix.xyz +[gtar] +gtar.comprofix.xyz diff --git a/ansible/main.yml b/ansible/main.yml index 8260059..bb11c4a 100644 --- a/ansible/main.yml +++ b/ansible/main.yml @@ -1,3 +1,30 @@ --- -- import_playbook: ghshr.yml +- name: Prepare all servers + hosts: all + become: true + vars: + alpine_latest_image: "alpine:latest" + ubuntu_latest_image: "node:22-trixie" + debian_latest_image: "git.comprofix.com/mmckinnon/debian-latest:2025.08.31-093853" + pre_tasks: + - name: Create directories + file: + path: "/data" + state: directory + + - name: Setup base system + import_tasks: tasks/base.yml + tags: base_setup + + roles: + - role: geerlingguy.docker + docker_users: + - administrator + tasks: + - name: Deploy docker apps + include_tasks: "tasks/{{ container }}.yml" + loop: + - gitea-runner + loop_control: + loop_var: container \ No newline at end of file diff --git a/ansible/requirements.yml b/ansible/requirements.yml new file mode 100644 index 0000000..0578fa1 --- /dev/null +++ b/ansible/requirements.yml @@ -0,0 +1,4 @@ +roles: + - name: geerlingguy.docker + src: git+https://github.com/geerlingguy/ansible-role-docker + version: master \ No newline at end of file diff --git a/ansible/tasks/create_folders.yml b/ansible/tasks/create_folders.yml new file mode 100644 index 0000000..acc2ea1 --- /dev/null +++ b/ansible/tasks/create_folders.yml @@ -0,0 +1,6 @@ +--- +- name: Create directories for {{ container }} + file: + path: "{{ data_folder }}/{{ container }}/{{ item }}" + state: directory + loop: "{{ subfolders | default(['config', 'data', 'logs']) }}" diff --git a/ansible/tasks/gitea-runner.yml b/ansible/tasks/gitea-runner.yml new file mode 100644 index 0000000..f7f2a4c --- /dev/null +++ b/ansible/tasks/gitea-runner.yml @@ -0,0 +1,40 @@ +- name: Create Folders + include_tasks: create_folders.yml + vars: + subfolders: + - config + +- name: Check that config.yaml exists + stat: + path: "{{ data_folder }}/gitea-runner/config/config.yaml" + register: configyaml + +- name: Create config.yaml file + file: + path: "{{ data_folder }}/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_folder }}/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://{{ alpine_latest_image }},ubuntu-latest:docker://{{ ubuntu_latest_image }},vps-latest:docker://{{ debian_latest_image }}" \ No newline at end of file diff --git a/opentofu/200-github.tf b/opentofu/200-gtar.tf similarity index 85% rename from opentofu/200-github.tf rename to opentofu/200-gtar.tf index 22ea219..5c9f4d6 100644 --- a/opentofu/200-github.tf +++ b/opentofu/200-gtar.tf @@ -1,8 +1,8 @@ -resource "proxmox_lxc" "ghshr" { +resource "proxmox_lxc" "gtar" { target_node = "pve" vmid = "200" - hostname = "ghshr" + hostname = "gtar" ostemplate = "local:vztmpl/debian-13-standard_13.1-1_amd64.tar.zst" password = var.ci_password unprivileged = false @@ -10,6 +10,8 @@ resource "proxmox_lxc" "ghshr" { onboot = true start = true startup = "order=1000" + tags = "gitea;container" + ssh_public_keys = <