From 78554a42140b3dc8671e67155a1b585a75634e5e Mon Sep 17 00:00:00 2001 From: Patrik Thormodsen Date: Wed, 25 Nov 2026 22:55:47 +0100 Subject: [PATCH 1/6] Added vt-booking host with docker compose role --- ansible/hosts.ini | 1 + ansible/playbook_infra.yml | 10 ++ ansible/roles/vt_booking/defaults/main.yml | 17 +++ ansible/roles/vt_booking/files/Makefile | 70 +++++++++ .../roles/vt_booking/files/compose.prod.yaml | 66 +++++++++ .../vt_booking/files/real-ip.conf.template | 7 + ansible/roles/vt_booking/handlers/main.yml | 29 ++++ ansible/roles/vt_booking/tasks/main.yml | 137 ++++++++++++++++++ .../roles/vt_booking/templates/daemon.json.j2 | 6 + ansible/roles/vt_booking/templates/env.j2 | 14 ++ .../roles/vt_booking/templates/nginx.conf.j2 | 71 +++++++++ .../templates/vt-booking-backup.sh.j2 | 14 ++ 12 files changed, 442 insertions(+) create mode 100644 ansible/roles/vt_booking/defaults/main.yml create mode 100644 ansible/roles/vt_booking/files/Makefile create mode 100644 ansible/roles/vt_booking/files/compose.prod.yaml create mode 100644 ansible/roles/vt_booking/files/real-ip.conf.template create mode 100644 ansible/roles/vt_booking/handlers/main.yml create mode 100644 ansible/roles/vt_booking/tasks/main.yml create mode 100644 ansible/roles/vt_booking/templates/daemon.json.j2 create mode 100644 ansible/roles/vt_booking/templates/env.j2 create mode 100644 ansible/roles/vt_booking/templates/nginx.conf.j2 create mode 100644 ansible/roles/vt_booking/templates/vt-booking-backup.sh.j2 diff --git a/ansible/hosts.ini b/ansible/hosts.ini index 118cd50..c0652a7 100644 --- a/ansible/hosts.ini +++ b/ansible/hosts.ini @@ -11,3 +11,4 @@ srib-radio azuracast-srib beszel kanidm +vt-booking diff --git a/ansible/playbook_infra.yml b/ansible/playbook_infra.yml index 71ca108..7b8a536 100644 --- a/ansible/playbook_infra.yml +++ b/ansible/playbook_infra.yml @@ -19,3 +19,13 @@ roles: - kanidm become: true + +- name: VT Booking host config + hosts: vt-booking + pre_tasks: + - name: Install nginx + ansible.builtin.include_role: + name: nginxinc.nginx + roles: + - vt_booking + become: true \ No newline at end of file diff --git a/ansible/roles/vt_booking/defaults/main.yml b/ansible/roles/vt_booking/defaults/main.yml new file mode 100644 index 0000000..af59e77 --- /dev/null +++ b/ansible/roles/vt_booking/defaults/main.yml @@ -0,0 +1,17 @@ +--- +# Domenet. Bytter dere senere, endrer du bare denne +vt_booking_domain: booking.fribyte.no + +# Hvor app-filene ligger på serveren +vt_booking_dir: /opt/vt-booking + +# Hvilken versjon av imagene: latest, eller en commit-SHA +vt_booking_image_tag: latest + +# Porten appens egen nginx lytter på, bare tilgjengelig fra serveren selv +vt_booking_http_port: 8080 + +# Fast adresseområde for Docker, så appens nettverk alltid får gateway 172.31.0.1 +vt_booking_docker_bip: 172.30.0.1/24 +vt_booking_docker_pool: 172.31.0.0/16 +vt_booking_trusted_proxy: 172.31.0.1 \ No newline at end of file diff --git a/ansible/roles/vt_booking/files/Makefile b/ansible/roles/vt_booking/files/Makefile new file mode 100644 index 0000000..f2ccae5 --- /dev/null +++ b/ansible/roles/vt_booking/files/Makefile @@ -0,0 +1,70 @@ +# Common tasks for the room booking system. Run `make help` for a list. +# Requires Docker, Java 21 and Node 22 (only Docker for `make up`). + +FRONTEND := frontend +BACKEND := backend +COMPOSE := docker compose +PROD := docker compose -f compose.prod.yaml +APP_PORT ?= 8088 +export APP_PORT + +.PHONY: help dev test up down reset-db bootstrap-admin prod-up prod-down prod-logs prod-update prod-pull prod-bootstrap-admin + +help: ## Show this list + @grep -E '^[a-z0-9-]+:.*## ' $(MAKEFILE_LIST) | awk -F ':.*## ' '{printf " make %-22s %s\n", $$1, $$2}' + +$(FRONTEND)/node_modules: $(FRONTEND)/package-lock.json + cd $(FRONTEND) && npm ci + @touch $@ + +dev: $(FRONTEND)/node_modules ## PostgreSQL in Docker, Spring Boot and React locally with hot reload + $(COMPOSE) up -d --wait db + @echo "Starting backend (:8080) and frontend (http://localhost:5173)." + @echo "Log in with your own account (first time: 'make bootstrap-admin' in another terminal). Ctrl+C stops both." + @# `exec` makes each job the real process, so the trap's kill reaches it. + @trap 'trap - INT TERM EXIT; kill $$(jobs -p) 2>/dev/null; wait' INT TERM EXIT; \ + (cd $(BACKEND) && exec ./mvnw -q spring-boot:run -Dspring-boot.run.profiles=dev) & \ + (cd $(FRONTEND) && exec npm run dev -- --strictPort) & \ + wait + +test: $(FRONTEND)/node_modules ## Frontend and backend tests (backend needs Docker for Testcontainers) + cd $(FRONTEND) && npm test + cd $(BACKEND) && ./mvnw -q test + +up: ## Build and run the complete application in Docker on http://localhost:8088 (APP_PORT to change) + $(COMPOSE) up -d --build --wait + @echo "Running on http://localhost:$(APP_PORT). First time: create an administrator with 'make bootstrap-admin'. Stop with 'make down'." + +bootstrap-admin: ## Create the first system administrator (prompts for email and password; refuses if one exists) + $(COMPOSE) run --rm --build backend bootstrap-admin + +down: ## Stop the containers (data is kept) + $(COMPOSE) down + +reset-db: ## Delete the development database (asks first) + @printf "Delete all data in the development database? [y/N] "; read answer; \ + case "$$answer" in \ + [yY]*) $(COMPOSE) down -v && echo "Database deleted. It is recreated empty on the next 'make dev' or 'make up'; then run 'make bootstrap-admin'." ;; \ + *) echo "Cancelled." ;; \ + esac + +# ── Production: compose.prod.yaml with settings in .env (see docs/DEPLOYMENT.md) ── + +prod-up: ## Production: start in the background (builds the images the first time) + $(PROD) up -d --wait + +prod-down: ## Production: stop the containers (the database is kept) + $(PROD) down + +prod-logs: ## Production: follow the logs of all services + $(PROD) logs -f --tail=100 + +prod-update: ## Production: rebuild the images from this checkout and restart (back up first) + $(PROD) up -d --build --wait + +prod-pull: ## Production: pull the images built by CI (IMAGE_TAG in .env) and restart (back up first) + $(PROD) pull backend frontend + $(PROD) up -d --no-build --wait + +prod-bootstrap-admin: ## Production: create the first system administrator (interactive) + $(PROD) run --rm backend bootstrap-admin diff --git a/ansible/roles/vt_booking/files/compose.prod.yaml b/ansible/roles/vt_booking/files/compose.prod.yaml new file mode 100644 index 0000000..354afe9 --- /dev/null +++ b/ansible/roles/vt_booking/files/compose.prod.yaml @@ -0,0 +1,66 @@ +# Production: PostgreSQL, the Spring Boot API and Nginx (the built React app), behind the host's +# HTTPS reverse proxy. Settings and secrets come from .env (copy .env.example). Use the +# `make prod-*` commands, and see docs/DEPLOYMENT.md. For development, use compose.yaml instead. +name: vt-booking-prod + +services: + db: + image: postgres:18-alpine + environment: + POSTGRES_DB: booking + POSTGRES_USER: booking + POSTGRES_PASSWORD: ${DB_PASSWORD:?Set DB_PASSWORD in .env} + volumes: + - pgdata:/var/lib/postgresql + healthcheck: + test: ["CMD-SHELL", "pg_isready -U booking -d booking"] + interval: 10s + timeout: 5s + retries: 10 + restart: unless-stopped + # No ports: only the API reaches the database. + + backend: + # Pulled from GHCR (built by .github/workflows/images.yml), or built locally with `make prod-update`. + image: ghcr.io/fribyte-code/vt-booking-backend:${IMAGE_TAG:-latest} + build: backend + environment: + # No SPRING_PROFILES_ACTIVE: the dev profile must never run in production. + DB_URL: jdbc:postgresql://db:5432/booking + DB_USER: booking + DB_PASSWORD: ${DB_PASSWORD:?Set DB_PASSWORD in .env} + depends_on: + db: + condition: service_healthy + healthcheck: + test: ["CMD", "curl", "-fsS", "-o", "/dev/null", "http://localhost:8080/api/auth/csrf"] + interval: 10s + timeout: 5s + start_period: 60s + retries: 6 + restart: unless-stopped + # No ports: only Nginx reaches the API. Never publish 8080 (see docs/DEPLOYMENT.md). + + frontend: + image: ghcr.io/fribyte-code/vt-booking-frontend:${IMAGE_TAG:-latest} + build: frontend + environment: + # The reverse proxy in front of Nginx, as Nginx sees it, and the header with the client address. + TRUSTED_PROXY: ${TRUSTED_PROXY:-127.0.0.1} + REAL_IP_HEADER: ${REAL_IP_HEADER:-X-Forwarded-For} + volumes: + - ./frontend/real-ip.conf.template:/etc/nginx/templates/real-ip.conf.template:ro + ports: + - "${HTTP_BIND:-127.0.0.1}:${HTTP_PORT:-8080}:80" + depends_on: + backend: + condition: service_healthy + healthcheck: + test: ["CMD", "curl", "-fsS", "-o", "/dev/null", "http://localhost/"] + interval: 10s + timeout: 5s + retries: 6 + restart: unless-stopped + +volumes: + pgdata: diff --git a/ansible/roles/vt_booking/files/real-ip.conf.template b/ansible/roles/vt_booking/files/real-ip.conf.template new file mode 100644 index 0000000..acaa747 --- /dev/null +++ b/ansible/roles/vt_booking/files/real-ip.conf.template @@ -0,0 +1,7 @@ +# Mounted by compose.prod.yaml. At start, the Nginx image fills in the variables (from .env) and +# writes the result to /etc/nginx/conf.d/real-ip.conf. Requests from TRUSTED_PROXY, the reverse +# proxy in front of Nginx, carry the client address in REAL_IP_HEADER; from anywhere else the +# header is ignored. The default, 127.0.0.1, trusts no proxy. +set_real_ip_from ${TRUSTED_PROXY}; +real_ip_header ${REAL_IP_HEADER}; +real_ip_recursive on; diff --git a/ansible/roles/vt_booking/handlers/main.yml b/ansible/roles/vt_booking/handlers/main.yml new file mode 100644 index 0000000..adc362e --- /dev/null +++ b/ansible/roles/vt_booking/handlers/main.yml @@ -0,0 +1,29 @@ +--- +- name: Restart docker + ansible.builtin.systemd_service: + name: docker + state: restarted + become: true + +# Same as `make prod-pull` in the app repository +- name: Pull vt-booking images + ansible.builtin.command: + cmd: docker compose -f compose.prod.yaml pull backend frontend + chdir: "{{ vt_booking_dir }}" + changed_when: true + listen: Deploy vt-booking + become: true + +- name: Start vt-booking + ansible.builtin.command: + cmd: docker compose -f compose.prod.yaml up -d --no-build --wait + chdir: "{{ vt_booking_dir }}" + changed_when: true + listen: Deploy vt-booking + become: true + +- name: Restart nginx + ansible.builtin.systemd_service: + name: nginx + state: restarted + become: true \ No newline at end of file diff --git a/ansible/roles/vt_booking/tasks/main.yml b/ansible/roles/vt_booking/tasks/main.yml new file mode 100644 index 0000000..cf1d911 --- /dev/null +++ b/ansible/roles/vt_booking/tasks/main.yml @@ -0,0 +1,137 @@ +--- +- name: Create the Docker config directory + ansible.builtin.file: + path: /etc/docker + state: directory + mode: "0755" + become: true + +- name: Write Docker daemon config + ansible.builtin.template: + src: templates/daemon.json.j2 + dest: /etc/docker/daemon.json + mode: "0644" + notify: Restart docker + become: true + +- name: Add the Docker apt repository + ansible.builtin.deb822_repository: + name: docker + types: deb + uris: https://download.docker.com/linux/debian + suites: "{{ ansible_facts['distribution_release'] }}" + components: stable + signed_by: https://download.docker.com/linux/debian/gpg + become: true + +- name: Install Docker, nginx ACME module and make + ansible.builtin.apt: + pkg: + - docker-ce + - docker-ce-cli + - containerd.io + - docker-compose-plugin + - nginx-module-acme + - make + state: present + update_cache: true + become: true + +- name: Start Docker on boot + ansible.builtin.systemd_service: + name: docker + state: started + enabled: true + become: true + + + + + - name: Check that the database password is set + ansible.builtin.assert: + that: + - vt_booking_db_password is defined + - vt_booking_db_password | length >= 32 + fail_msg: Set vt_booking_db_password in group_vars/all.yml (openssl rand -hex 32) + quiet: true + +- name: Create the app directories + ansible.builtin.file: + path: "{{ item }}" + state: directory + mode: "0755" + loop: + - "{{ vt_booking_dir }}" + - "{{ vt_booking_dir }}/frontend" + become: true + +- name: Copy the app's compose file, Makefile and real-ip template + ansible.builtin.copy: + src: "files/{{ item.src }}" + dest: "{{ vt_booking_dir }}/{{ item.dest }}" + mode: "0644" + loop: + - { src: compose.prod.yaml, dest: compose.prod.yaml } + - { src: Makefile, dest: Makefile } + - { src: real-ip.conf.template, dest: frontend/real-ip.conf.template } + notify: Deploy vt-booking + become: true + +- name: Write the app's .env + ansible.builtin.template: + src: templates/env.j2 + dest: "{{ vt_booking_dir }}/.env" + mode: "0600" + notify: Deploy vt-booking + become: true + + + + - name: Write nginx config + ansible.builtin.template: + src: templates/nginx.conf.j2 + dest: /etc/nginx/nginx.conf + mode: "0644" + validate: /usr/sbin/nginx -t -c %s + notify: Restart nginx + become: true + + + - name: Create the backup directory + ansible.builtin.file: + path: /var/backups/vt-booking + state: directory + mode: "0700" + become: true + +- name: Write the backup script + ansible.builtin.template: + src: templates/vt-booking-backup.sh.j2 + dest: /usr/local/sbin/vt-booking-backup + mode: "0755" + become: true + +- name: Back up the database every night + ansible.builtin.cron: + name: vt-booking backup + minute: "15" + hour: "3" + job: /usr/local/sbin/vt-booking-backup + user: root + become: true + +- name: Deploy pending changes + ansible.builtin.meta: flush_handlers + +- name: Read the gateway of the app's Docker network + ansible.builtin.command: + cmd: docker network inspect vt-booking-prod_default --format {% raw %}'{{ range .IPAM.Config }}{{ .Gateway }}{{ end }}'{% endraw %} + register: vt_booking_gateway + changed_when: false + become: true + +- name: Check that the gateway is the trusted proxy + ansible.builtin.assert: + that: vt_booking_gateway.stdout == vt_booking_trusted_proxy + fail_msg: "Gateway is {{ vt_booking_gateway.stdout }}, TRUSTED_PROXY is {{ vt_booking_trusted_proxy }}" + quiet: true \ No newline at end of file diff --git a/ansible/roles/vt_booking/templates/daemon.json.j2 b/ansible/roles/vt_booking/templates/daemon.json.j2 new file mode 100644 index 0000000..59f8330 --- /dev/null +++ b/ansible/roles/vt_booking/templates/daemon.json.j2 @@ -0,0 +1,6 @@ +{ + "bip": "{{ vt_booking_docker_bip }}", + "default-address-pools": [ + { "base": "{{ vt_booking_docker_pool }}", "size": 24 } + ] +} \ No newline at end of file diff --git a/ansible/roles/vt_booking/templates/env.j2 b/ansible/roles/vt_booking/templates/env.j2 new file mode 100644 index 0000000..9ca3f99 --- /dev/null +++ b/ansible/roles/vt_booking/templates/env.j2 @@ -0,0 +1,14 @@ +# {{ ansible_managed }} +# Settings for compose.prod.yaml. See .env.example and docs/DEPLOYMENT.md in the app repository. + +DB_PASSWORD={{ vt_booking_db_password }} + +# Only the nginx on this host connects to the app +HTTP_BIND=127.0.0.1 +HTTP_PORT={{ vt_booking_http_port }} + +# The host nginx, as the app's nginx sees it: the gateway of the compose network +TRUSTED_PROXY={{ vt_booking_trusted_proxy }} +REAL_IP_HEADER=X-Forwarded-For + +IMAGE_TAG={{ vt_booking_image_tag }} \ No newline at end of file diff --git a/ansible/roles/vt_booking/templates/nginx.conf.j2 b/ansible/roles/vt_booking/templates/nginx.conf.j2 new file mode 100644 index 0000000..514f37e --- /dev/null +++ b/ansible/roles/vt_booking/templates/nginx.conf.j2 @@ -0,0 +1,71 @@ +# {{ ansible_managed }} +load_module modules/ngx_http_acme_module.so; + +user nginx nginx; +worker_processes auto; +worker_rlimit_nofile 2048; + +pid /run/nginx.pid; +error_log /var/log/nginx/error.log notice; + +events { + worker_connections 1024; +} + +http { + include /etc/nginx/mime.types; + default_type application/octet-stream; + + log_format main '$remote_addr - $remote_user [$time_local] "$request" ' + '$status $body_bytes_sent "$http_referer" ' + '"$http_user_agent" "$http_x_forwarded_for"'; + + access_log /var/log/nginx/access.log main; + + sendfile on; + gzip on; + keepalive_timeout 10; + server_tokens off; + + resolver 1.1.1.1; + + ### For ssl cert + acme_issuer letsencrypt { + uri https://acme-v02.api.letsencrypt.org/directory; + state_path /var/cache/nginx/acme-letsencrypt; + + accept_terms_of_service; + } + + ### General listener on port 80 is required to process ACME HTTP-01 challenges + server { + listen 80 default_server; + listen [::]:80 default_server; + + ### Redirect to https + return 301 https://$host$request_uri; + } + + server { + listen 443 ssl; + listen [::]:443 ssl; + + server_name {{ vt_booking_domain }}; + + ### SSL + acme_certificate letsencrypt; + ssl_certificate $acme_certificate; + ssl_certificate_key $acme_certificate_key; + ssl_certificate_cache max=2; + + ### The app's own nginx (frontend container), which passes /api on to the backend + location / { + proxy_pass http://127.0.0.1:{{ vt_booking_http_port }}; + proxy_http_version 1.1; + proxy_set_header Host $host; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-Proto $scheme; + } + } +} \ No newline at end of file diff --git a/ansible/roles/vt_booking/templates/vt-booking-backup.sh.j2 b/ansible/roles/vt_booking/templates/vt-booking-backup.sh.j2 new file mode 100644 index 0000000..875226f --- /dev/null +++ b/ansible/roles/vt_booking/templates/vt-booking-backup.sh.j2 @@ -0,0 +1,14 @@ +#!/bin/sh +# {{ ansible_managed }} +# Nightly dump of the VT Booking database, as in docs/DEPLOYMENT.md in the app repository. +set -eu + +cd {{ vt_booking_dir }} +file=/var/backups/vt-booking/vt-booking-$(date +%F).dump + +# Write to a temporary file first, so a failed dump never replaces a good one +docker compose -f compose.prod.yaml exec -T db pg_dump -U booking -Fc booking > "$file.tmp" +mv "$file.tmp" "$file" + +# Keep 14 days +find /var/backups/vt-booking -name 'vt-booking-*.dump' -mtime +14 -delete \ No newline at end of file From 1feeaa97a3dfc0b6bf5b938c3fbba26aba2ed3f2 Mon Sep 17 00:00:00 2001 From: Patrik Thormodsen Date: Thu, 26 Nov 2026 10:24:35 +0100 Subject: [PATCH 2/6] Fixed ansible lint errors --- ansible/playbook_infra.yml | 2 +- ansible/roles/vt_booking/defaults/main.yml | 2 +- ansible/roles/vt_booking/handlers/main.yml | 2 +- ansible/roles/vt_booking/tasks/main.yml | 14 ++++---------- 4 files changed, 7 insertions(+), 13 deletions(-) diff --git a/ansible/playbook_infra.yml b/ansible/playbook_infra.yml index 7b8a536..67d349f 100644 --- a/ansible/playbook_infra.yml +++ b/ansible/playbook_infra.yml @@ -28,4 +28,4 @@ name: nginxinc.nginx roles: - vt_booking - become: true \ No newline at end of file + become: true diff --git a/ansible/roles/vt_booking/defaults/main.yml b/ansible/roles/vt_booking/defaults/main.yml index af59e77..7804f28 100644 --- a/ansible/roles/vt_booking/defaults/main.yml +++ b/ansible/roles/vt_booking/defaults/main.yml @@ -14,4 +14,4 @@ vt_booking_http_port: 8080 # Fast adresseområde for Docker, så appens nettverk alltid får gateway 172.31.0.1 vt_booking_docker_bip: 172.30.0.1/24 vt_booking_docker_pool: 172.31.0.0/16 -vt_booking_trusted_proxy: 172.31.0.1 \ No newline at end of file +vt_booking_trusted_proxy: 172.31.0.1 diff --git a/ansible/roles/vt_booking/handlers/main.yml b/ansible/roles/vt_booking/handlers/main.yml index adc362e..3d8ff5d 100644 --- a/ansible/roles/vt_booking/handlers/main.yml +++ b/ansible/roles/vt_booking/handlers/main.yml @@ -26,4 +26,4 @@ ansible.builtin.systemd_service: name: nginx state: restarted - become: true \ No newline at end of file + become: true diff --git a/ansible/roles/vt_booking/tasks/main.yml b/ansible/roles/vt_booking/tasks/main.yml index cf1d911..a32f0ff 100644 --- a/ansible/roles/vt_booking/tasks/main.yml +++ b/ansible/roles/vt_booking/tasks/main.yml @@ -44,10 +44,7 @@ enabled: true become: true - - - - - name: Check that the database password is set +- name: Check that the database password is set ansible.builtin.assert: that: - vt_booking_db_password is defined @@ -85,9 +82,7 @@ notify: Deploy vt-booking become: true - - - - name: Write nginx config +- name: Write nginx config ansible.builtin.template: src: templates/nginx.conf.j2 dest: /etc/nginx/nginx.conf @@ -96,8 +91,7 @@ notify: Restart nginx become: true - - - name: Create the backup directory +- name: Create the backup directory ansible.builtin.file: path: /var/backups/vt-booking state: directory @@ -134,4 +128,4 @@ ansible.builtin.assert: that: vt_booking_gateway.stdout == vt_booking_trusted_proxy fail_msg: "Gateway is {{ vt_booking_gateway.stdout }}, TRUSTED_PROXY is {{ vt_booking_trusted_proxy }}" - quiet: true \ No newline at end of file + quiet: true From 0d255d8245d7cbd6b5d8c84e17a40e95462e3c63 Mon Sep 17 00:00:00 2001 From: Patrik Thormodsen Date: Fri, 27 Nov 2026 14:43:23 +0100 Subject: [PATCH 3/6] Changes env variable --- ansible/group_vars/all.yml | 51 ++++++++++++++++++++++++-------------- edit_group_variables.sh | 4 +-- local_run_config.sh | 2 +- run_config.sh | 2 +- setup_ansible.sh | 2 +- 5 files changed, 38 insertions(+), 23 deletions(-) diff --git a/ansible/group_vars/all.yml b/ansible/group_vars/all.yml index 1fc47b4..7d0c114 100644 --- a/ansible/group_vars/all.yml +++ b/ansible/group_vars/all.yml @@ -1,19 +1,34 @@ $ANSIBLE_VAULT;1.1;AES256 -35323132643564396232333034306638623934636533313039653861353465303732373131666161 -6238303664356561663936333662666163323932653836360a333237396332636339303535646533 -37356633353263633163646436343462626638666639346662383831616134643863363261636563 -3866653936373538350a643666316365616235303036613066383030656166386166643661336534 -32653662393136653133373033356130623833343831306562626662376536303237306233303638 -30356538373964386164366430316465633464646132643931373232313666626535333666663466 -32633537333133333838656234646537326339363633646636313234636532376133303963306638 -32303734633462396330626363386530386465366565306233326430663164623236663061386330 -63616562303337303933353734623535373939313363356431366264643531383761396230373338 -38386364363063316163306365656533373034623734346432353230633837646266636231363264 -33353937656130656335313763363762386663386236376532636265363163656337646562346632 -32363761316134373363616464623030343137373338643532666138376139616431323436313063 -62363137633732643830653665663333333963653532616531353064303563383334393239656465 -31333332373265316336643762386432383432366130303135333362343030333537323865643036 -65646639386437656365613134393936363132313639393966313162323437373236316239666631 -35333961333435613139353235356637663235616261373165323031393264363965333435316331 -30373238316235613937663966356438663961633336366436306235303135633362303737636338 -3062666462303436613761613065623536356462616565366433 +32633338343462363831313131386237613135333263643036646139633063643830613765613434 +6532376663346465306461373034353438316537343238310a343761643930353039663263346262 +39383931333132303763376534653736626239303461343330663136616564393661383133336163 +6561646530376462300a396361336335663466656335343466633533646634653264303862376135 +39313763633661633832626234353136653161623566373835323462666464613236366139383933 +63626262356365616434376263656438626633643130376461366366353662373162353033386431 +37333961316234343936616463636132313034346661316335663264303063396136663066326664 +37306334643337623537613766623835323639386639393138663330316437653139633136373431 +63636262393765343933323463643865646566303639656339666131613563393461336431613465 +39373337346133623836333562623734623338366164396635306464376130303964373565346664 +63343535623032356362613737383439373038313432333964623330383233383234363461613331 +33653533396335376530343464316261343064356133366237363365633063613036323663656131 +33616634306234666663623363326562323562623032363438363133663535653834646435636634 +38656136633331396134313537326533616337373264363634353436643466313535663239313439 +64636339313766393737626532626462616335323931363666353334616237636133656162343538 +34666564623337636332333336663765663264633635313339386338323366326461626330323836 +34393230303136343764376131353735636662353966323435376130346161666162653438663361 +62336363373736363466313331343535343766373161323832356430636439616239376665613534 +62623039386236336664346530663536666238303930333336613763616165333738376231316562 +31373938346236333163303631336139653831656137316534666265356264323934316130303339 +65656161336663366264616164303362376530323939613761663364303966343661313330613862 +31313038646338343430373639313431373763633935383861396536336537363862316163303162 +38333338613432636337636434386633633564623932313934613831626132306465326438396362 +33663462373266356464333966663635376234343666313630643233613063623936366230333134 +36313164626661626339313837613834633463653837336635646466373731386237363365626538 +34623933373834656237643032333363313134323064353538633534336539633131653562306631 +38373235613662366230653561326366316231326562626433353134303932633061333337623239 +30363162373265363734613563653966643439653763376166333235646637343530613137396339 +30323030653866363533643630626635346133653434316566643331323065393637343630356131 +62386531323335356434646561663832363931353339633561396437373332326561306638333663 +33363763303666356165306538306364613338343564353932346265323338633637346338613732 +61303664356163393931613530643664303761613833653531653262393737346338613666353335 +38316235316439363431343761326237373162646334333661633730613830356463 diff --git a/edit_group_variables.sh b/edit_group_variables.sh index f1d49b6..aee9c48 100755 --- a/edit_group_variables.sh +++ b/edit_group_variables.sh @@ -1,10 +1,10 @@ -#! /usr/bin/bash +#! /usr/bin/env bash cd ansible echo "Opening group vars in editor" -ansible-vault edit group_vars/all.yml --vault-password-file .ansible_vault_key +env EDITOR=nano ansible-vault edit group_vars/all.yml --vault-password-file .ansible_vault_key if [ $? -ne 0 ]; then echo "Error in writing group vars file, have you created a vault password file?" diff --git a/local_run_config.sh b/local_run_config.sh index b1d9217..b51ad18 100755 --- a/local_run_config.sh +++ b/local_run_config.sh @@ -1,4 +1,4 @@ -#! /usr/bin/bash +#! /usr/bin/env bash cd ansible diff --git a/run_config.sh b/run_config.sh index a3e764d..3df7f33 100755 --- a/run_config.sh +++ b/run_config.sh @@ -1,4 +1,4 @@ -#! /usr/bin/bash +#! /usr/bin/env bash pushd ansible diff --git a/setup_ansible.sh b/setup_ansible.sh index bc26e3c..d3b0c8a 100755 --- a/setup_ansible.sh +++ b/setup_ansible.sh @@ -1,4 +1,4 @@ -#! /usr/bin/bash +#! /usr/bin/env bash pushd ansible From 26184b739d5457c60f25f46a2b77a5aaf25fccbc Mon Sep 17 00:00:00 2001 From: Patrik Thormodsen Date: Fri, 27 Nov 2026 14:56:03 +0100 Subject: [PATCH 4/6] Updated group vars --- ansible/group_vars/all.yml | 68 +++++++++++++++-------------- ansible/roles/common/tasks/main.yml | 1 - run_config.sh | 2 +- 3 files changed, 36 insertions(+), 35 deletions(-) diff --git a/ansible/group_vars/all.yml b/ansible/group_vars/all.yml index 7d0c114..35612c2 100644 --- a/ansible/group_vars/all.yml +++ b/ansible/group_vars/all.yml @@ -1,34 +1,36 @@ $ANSIBLE_VAULT;1.1;AES256 -32633338343462363831313131386237613135333263643036646139633063643830613765613434 -6532376663346465306461373034353438316537343238310a343761643930353039663263346262 -39383931333132303763376534653736626239303461343330663136616564393661383133336163 -6561646530376462300a396361336335663466656335343466633533646634653264303862376135 -39313763633661633832626234353136653161623566373835323462666464613236366139383933 -63626262356365616434376263656438626633643130376461366366353662373162353033386431 -37333961316234343936616463636132313034346661316335663264303063396136663066326664 -37306334643337623537613766623835323639386639393138663330316437653139633136373431 -63636262393765343933323463643865646566303639656339666131613563393461336431613465 -39373337346133623836333562623734623338366164396635306464376130303964373565346664 -63343535623032356362613737383439373038313432333964623330383233383234363461613331 -33653533396335376530343464316261343064356133366237363365633063613036323663656131 -33616634306234666663623363326562323562623032363438363133663535653834646435636634 -38656136633331396134313537326533616337373264363634353436643466313535663239313439 -64636339313766393737626532626462616335323931363666353334616237636133656162343538 -34666564623337636332333336663765663264633635313339386338323366326461626330323836 -34393230303136343764376131353735636662353966323435376130346161666162653438663361 -62336363373736363466313331343535343766373161323832356430636439616239376665613534 -62623039386236336664346530663536666238303930333336613763616165333738376231316562 -31373938346236333163303631336139653831656137316534666265356264323934316130303339 -65656161336663366264616164303362376530323939613761663364303966343661313330613862 -31313038646338343430373639313431373763633935383861396536336537363862316163303162 -38333338613432636337636434386633633564623932313934613831626132306465326438396362 -33663462373266356464333966663635376234343666313630643233613063623936366230333134 -36313164626661626339313837613834633463653837336635646466373731386237363365626538 -34623933373834656237643032333363313134323064353538633534336539633131653562306631 -38373235613662366230653561326366316231326562626433353134303932633061333337623239 -30363162373265363734613563653966643439653763376166333235646637343530613137396339 -30323030653866363533643630626635346133653434316566643331323065393637343630356131 -62386531323335356434646561663832363931353339633561396437373332326561306638333663 -33363763303666356165306538306364613338343564353932346265323338633637346338613732 -61303664356163393931613530643664303761613833653531653262393737346338613666353335 -38316235316439363431343761326237373162646334333661633730613830356463 +31396433313935656433323162323539653631343730356235353965616339356235323238373230 +3436326438636366393637643665656364346531623730320a643535316433353862313330336430 +32343231623733336166303433616436313831666536636333323332393132353139623161353336 +3561323831313865650a376131666439663038333737386534396232613338326135363266336439 +35353739633363623733646532633565306632336234373763323862306134333733316266373537 +37643564333266373861393564373031653661616430313765663236623933613961356462636433 +63643136306639333530326432653233613361396664333266343132636566343061376434336335 +61333162373061623665303838363064613063393732353835323031323830303162666132333239 +39356233343836643764383332356237313034383663656538316434633132333038633839636661 +31343866633130356365396265666165393862656133323965653864373531306433333135373532 +39616139623963306338666663636531393837353964346661366564323231363233623863356361 +39646636616130663064313661656237653265303735356337613862643839343738633135363138 +30626263313438346238616262656431656461383365333861306263386435386265393730363737 +66376138643039393565383837623437633131396465383136646639376262323866363238623062 +33646536643565313662306362636537343362373331633833336235376133633064623566363337 +31366130653932343930633436303763376532343561613731336330303032383437633362393831 +65636334393363376166343835363062653964393136633234383533333639353639636139306565 +34313532353736313266616233386339373736373266346534666464336236393439613365396264 +63373866663439373133333033363663366536376239333531613061356362616230306236346630 +38333739323566666666656433616264643934626566633663353133653438646262353432633533 +35323435376533643166653236323133663061386135393435393436313962326535343236666166 +37303833336362343061356233376337303861363432656534356130306136356462343237343339 +35666462613538336139623764363131383863653066373730613130336136303731626531663761 +37326464653439366265313365303733363634383834613631386536643961626539323364336465 +31646339653532623437616438386463633331616661616366626132356163393238356237646231 +33356562656164666663656665646330316165303161386231333764643934643963363036323961 +61623662306438633633346462653861353330636130386364356235343737636663373431666365 +63343461633831663234353736623032363432313865626139366666666263663039663733353330 +31616666663932306332356431663338373463646162376261623539353132613066363535623665 +30376139663462626362363965313730353064666463386662613831343030396634303238306438 +34343531353833303432303031633065366364326237333563346332333832633766623639656464 +61343836636563633535343965333438326333643761343064396537363937623232373039323730 +61313561393365663832633862306434363663623637383732613238633334303636343061356261 +62353834393237323139373836393233626665366231666636353139616530363766303964346134 +656337376464306361643130393562363634 diff --git a/ansible/roles/common/tasks/main.yml b/ansible/roles/common/tasks/main.yml index b6f4b21..8637381 100644 --- a/ansible/roles/common/tasks/main.yml +++ b/ansible/roles/common/tasks/main.yml @@ -28,5 +28,4 @@ - tmux - dnsutils - qemu-guest-agent - - podman become: true diff --git a/run_config.sh b/run_config.sh index 3df7f33..f71d5e9 100755 --- a/run_config.sh +++ b/run_config.sh @@ -14,4 +14,4 @@ fi echo "Switching to friByte tailnet" tailscale switch headscale.fribyte.no -ansible-playbook playbook_infra.yml --become-password-file .ansible_sudo_password --vault-password-file .ansible_vault_key +ansible-playbook playbook_infra.yml --vault-password-file .ansible_vault_key From 4c485f75ecc0d2d051f1b703a8ee769b1ab34e11 Mon Sep 17 00:00:00 2001 From: Patrik Thormodsen Date: Fri, 27 Nov 2026 15:57:25 +0100 Subject: [PATCH 5/6] final edits --- ansible/group_vars/all.yml | 60 +++++++++++-------------- ansible/roles/vt_booking/tasks/main.yml | 12 +++++ 2 files changed, 37 insertions(+), 35 deletions(-) diff --git a/ansible/group_vars/all.yml b/ansible/group_vars/all.yml index 35612c2..ce47286 100644 --- a/ansible/group_vars/all.yml +++ b/ansible/group_vars/all.yml @@ -1,36 +1,26 @@ $ANSIBLE_VAULT;1.1;AES256 -31396433313935656433323162323539653631343730356235353965616339356235323238373230 -3436326438636366393637643665656364346531623730320a643535316433353862313330336430 -32343231623733336166303433616436313831666536636333323332393132353139623161353336 -3561323831313865650a376131666439663038333737386534396232613338326135363266336439 -35353739633363623733646532633565306632336234373763323862306134333733316266373537 -37643564333266373861393564373031653661616430313765663236623933613961356462636433 -63643136306639333530326432653233613361396664333266343132636566343061376434336335 -61333162373061623665303838363064613063393732353835323031323830303162666132333239 -39356233343836643764383332356237313034383663656538316434633132333038633839636661 -31343866633130356365396265666165393862656133323965653864373531306433333135373532 -39616139623963306338666663636531393837353964346661366564323231363233623863356361 -39646636616130663064313661656237653265303735356337613862643839343738633135363138 -30626263313438346238616262656431656461383365333861306263386435386265393730363737 -66376138643039393565383837623437633131396465383136646639376262323866363238623062 -33646536643565313662306362636537343362373331633833336235376133633064623566363337 -31366130653932343930633436303763376532343561613731336330303032383437633362393831 -65636334393363376166343835363062653964393136633234383533333639353639636139306565 -34313532353736313266616233386339373736373266346534666464336236393439613365396264 -63373866663439373133333033363663366536376239333531613061356362616230306236346630 -38333739323566666666656433616264643934626566633663353133653438646262353432633533 -35323435376533643166653236323133663061386135393435393436313962326535343236666166 -37303833336362343061356233376337303861363432656534356130306136356462343237343339 -35666462613538336139623764363131383863653066373730613130336136303731626531663761 -37326464653439366265313365303733363634383834613631386536643961626539323364336465 -31646339653532623437616438386463633331616661616366626132356163393238356237646231 -33356562656164666663656665646330316165303161386231333764643934643963363036323961 -61623662306438633633346462653861353330636130386364356235343737636663373431666365 -63343461633831663234353736623032363432313865626139366666666263663039663733353330 -31616666663932306332356431663338373463646162376261623539353132613066363535623665 -30376139663462626362363965313730353064666463386662613831343030396634303238306438 -34343531353833303432303031633065366364326237333563346332333832633766623639656464 -61343836636563633535343965333438326333643761343064396537363937623232373039323730 -61313561393365663832633862306434363663623637383732613238633334303636343061356261 -62353834393237323139373836393233626665366231666636353139616530363766303964346134 -656337376464306361643130393562363634 +61363761383764636162396639656633356361363761373834663965303637626262383834336265 +3834363165356137623130313562636366616433316666330a316535643536333638383038313838 +31333133643763303530316535633934666437373834663137613337323234646265386361343763 +6632373238346164650a386438373065656361623032646566613437323137353063343438393566 +33646230653366343634623363366134616364373163323433613032633665613732616634363762 +66346438323130396534623631326339616634663261363061363136306334386361353834333534 +39336638623939323133353362323034356132623161393932386161626638313663623733353232 +35656237666464646131376466353339363932666535633738333035353536306630323038353531 +32313432316233653436333632326231386235643237643833326163373362306338626332393434 +38633032623438636265636131666638663532393537663763633961633663633434393933663461 +38333333393437373636346231306237656665393331363465353635393530396565333039366137 +37333239663563376631333162373738343234336538646537353464303763633763626132346238 +34326631643165393937643131323539616532663366366533386633663765303764653939396564 +32383861346534633364656539316130373035303039373033363338643237393565616562393665 +39363235313535306531656535623134373665386536623836666362306133343437303132653138 +30396138343262613761636138616565346236353936396431336337306262383034623464366335 +65643966326365353636343637613035633564666436623636613239633335633064383034393035 +31363134393861623762646561656632653635653436363666643230383732363734653439373965 +30623537353738643939393734303135316364376465653964623561346434653939376465663334 +30643132663532613366393262656166323236633730613037383030393264626534313862376366 +36303462386561316339363165396638636531333431613138613134393234666638376235333763 +63373366353530613736663531336331376265303464343761333236626130313332333564616231 +31333665316432386435663436373862333031373738323064316136373464653437633462663836 +33313338343533373832353063626439363663383563666133353866653362343734376566316466 +3632 diff --git a/ansible/roles/vt_booking/tasks/main.yml b/ansible/roles/vt_booking/tasks/main.yml index a32f0ff..2140996 100644 --- a/ansible/roles/vt_booking/tasks/main.yml +++ b/ansible/roles/vt_booking/tasks/main.yml @@ -33,6 +33,7 @@ - docker-compose-plugin - nginx-module-acme - make + - cron state: present update_cache: true become: true @@ -117,6 +118,17 @@ - name: Deploy pending changes ansible.builtin.meta: flush_handlers +- name: Start vt-booking stack + community.docker.docker_compose_v2: + project_src: "{{ vt_booking_dir }}" + files: + - compose.prod.yaml + state: present + pull: missing + build: never + wait: true + become: true + - name: Read the gateway of the app's Docker network ansible.builtin.command: cmd: docker network inspect vt-booking-prod_default --format {% raw %}'{{ range .IPAM.Config }}{{ .Gateway }}{{ end }}'{% endraw %} From eaa5f5c67263aff027f9fa09a38b5932271b15eb Mon Sep 17 00:00:00 2001 From: Patrik Thormodsen Date: Fri, 27 Nov 2026 16:00:51 +0100 Subject: [PATCH 6/6] Added community docker requirements --- ansible/requirements.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ansible/requirements.yml b/ansible/requirements.yml index 6fe23b1..f05c421 100644 --- a/ansible/requirements.yml +++ b/ansible/requirements.yml @@ -4,6 +4,8 @@ collections: version: "2.2.2" - name: community.beszel version: "2.0.0" + - name: community.docker + version: "5.4.0" roles: - name: nginxinc.nginx version: "0.26.0"