Compare commits

...
7 Commits
Author SHA1 Message Date
mark 2dc4b4443a aurbis access to /opt 2026-10-07 18:49:38 +02:00
mark 26449924b8 shared gitea checkouts 2026-10-07 18:23:28 +02:00
mark fffc009ab9 jellyfin 12 2026-09-08 09:55:46 +02:00
mark c06ab18da9 nightingale cache and mem limits 2026-09-04 10:53:04 +02:00
mark 7e8898a042 swapfile 2026-09-04 10:52:50 +02:00
mark 1782a9bf47 fail2ban 2026-09-03 22:11:57 +02:00
mark 682d8d571c bump and pin images 2026-08-09 20:44:30 +02:00
20 changed files with 264 additions and 54 deletions

No files matched your search

+2
View File
@@ -0,0 +1,2 @@
gitea_ssh: gitea@git.hoekveen.net
gitea_https: https://git.hoekveen.net
+5
View File
@@ -27,3 +27,8 @@
service:
name: nginx
state: reloaded
- name: restart fail2ban
service:
name: fail2ban
state: restarted
+7 -1
View File
@@ -4,6 +4,9 @@ users:
- jp
- lourens
- guus
# nightingale's analyzer peaks around 11G RSS during forced alignment, on 11G of RAM.
swapfile_size_gb: 24
cloud_nginx_tls: true
cloud_nginx_sites:
- name: nextcloud
@@ -30,8 +33,11 @@ cloud_nginx_sites:
port: 8087
max_body: 2g # song uploads
fail2ban_ignoreip:
- home.hoekveen.net
stroopwafel_dir: /opt/stroopwafel
stroopwafel_repo: gitea@git.hoekveen.net:mark/stroopwafel.git
stroopwafel_repo: mark/stroopwafel
stroopwafel_version: master
backup_dump_dir: /var/backups/aurbis
+21 -8
View File
@@ -61,12 +61,20 @@
tasks:
- name: Update
include_tasks: tasks/install_docker_debian.yml
- name: Aurbis access to /opt
hosts: all
become: true
remote_user: nerevar
tasks:
- import_tasks: tasks/aurbis.yml
tags: aurbis
- name: Add utility scripts
hosts: all
become: true
remote_user: nerevar
tasks:
- import_tasks: tasks/scripts.yml
tags: scripts
- name: Setup zsh
hosts: debian
become: true
@@ -109,19 +117,24 @@
package:
name: [rsync, curl, sqlite3]
state: present
- name: Normalise /opt app ownership to root:aurbis (top dir only, not recursive)
file:
path: "/opt/{{ item }}"
state: directory
owner: root
group: aurbis
mode: "0775"
loop: [nextcloud, hdwiki, gitea, authentik, drone, "hoekveen.net"]
- import_tasks: tasks/aurbis_tree.yml
vars:
tree_path: /opt/hoekveen.net
tags: aurbis
- import_tasks: tasks/swapfile.yml
tags: swap
- import_tasks: tasks/nextcloud.yml
tags: nextcloud
- import_tasks: tasks/hdwiki.yml
tags: hdwiki
- import_tasks: tasks/gitea.yml
tags: gitea
- import_tasks: tasks/nightingale.yml
tags: nightingale
- import_tasks: tasks/stroopwafel.yml
tags: stroopwafel
- import_tasks: tasks/fail2ban.yml
tags: fail2ban
- import_tasks: tasks/cloud_nginx.yml
- name: Ensure the backup user can run the forced-command pull
user:
+41
View File
@@ -0,0 +1,41 @@
# Service data below the top level stays with whatever uid its container runs as.
- name: Let aurbis create services in /opt
file:
path: /opt
state: directory
owner: root
group: aurbis
mode: "02775"
- name: Give aurbis every /opt service directory
ansible.builtin.command:
argv: [find, /opt, -mindepth, "1", -maxdepth, "1", -type, d, "!", -name, containerd,
"!", "(", -group, aurbis, -perm, "-2070", ")",
-print, -exec, chgrp, aurbis, "{}", "+", -exec, chmod, g+rwxs, "{}", "+"]
register: aurbis_opt_dirs
changed_when: aurbis_opt_dirs.stdout != ""
- name: Give aurbis the top-level files of every /opt service
ansible.builtin.command:
argv: [find, /opt, -mindepth, "2", -maxdepth, "2", -type, f, "!", -path, "/opt/containerd/*",
"!", "(", -group, aurbis, -perm, -g+rw, ")",
-print, -exec, chgrp, aurbis, "{}", "+", -exec, chmod, g+rw, "{}", "+"]
register: aurbis_opt_files
changed_when: aurbis_opt_files.stdout != ""
- name: Keep /opt .env files from other users
ansible.builtin.command:
argv: [find, /opt, -mindepth, "2", -maxdepth, "2", -type, f, -name, .env, -perm, /o+rwx,
-print, -exec, chmod, o-rwx, "{}", "+"]
register: aurbis_opt_env
changed_when: aurbis_opt_env.stdout != ""
- name: Look up the docker group
getent:
database: group
key: docker
fail_key: false
- name: Let aurbis members run docker
user:
name: "{{ item }}"
groups: docker
append: true
loop: "{{ users | default([]) }}"
when: ansible_facts.getent_group.docker is not none
+12
View File
@@ -0,0 +1,12 @@
- name: Give aurbis write access to {{ tree_path }}
file:
path: "{{ tree_path }}"
state: directory
recurse: true
group: aurbis
mode: g+rwX
- name: Make {{ tree_path }} directories hand their group to new files
ansible.builtin.command:
cmd: "find {{ tree_path }} -type d ! -perm -g+s -print -exec chmod g+s {} +"
register: aurbis_tree_setgid
changed_when: aurbis_tree_setgid.stdout != ""
+1 -1
View File
@@ -10,7 +10,7 @@
state: directory
owner: root
group: "{{ service_group | default('aurbis') }}"
mode: "0775"
mode: "02775"
- name: Copy docker-compose file
template:
src: "{{ service_name }}/docker-compose.yml.j2"
+17
View File
@@ -0,0 +1,17 @@
- name: Install fail2ban
apt:
name: [fail2ban, python3-systemd]
state: present
- name: Configure sshd jail
template:
src: fail2ban/sshd.local.j2
dest: /etc/fail2ban/jail.d/sshd.local
owner: root
group: root
mode: "0644"
notify: restart fail2ban
- name: Enable fail2ban
service:
name: fail2ban
state: started
enabled: true
+14
View File
@@ -0,0 +1,14 @@
[DEFAULT]
backend = systemd
banaction = nftables-multiport
banaction_allports = nftables-allports
ignoreip = {{ (['127.0.0.1/8', '::1'] + fail2ban_ignoreip | default([])) | join(' ') }}
bantime = {{ fail2ban_bantime | default('1h') }}
bantime.increment = true
bantime.maxtime = {{ fail2ban_bantime_max | default('1w') }}
findtime = {{ fail2ban_findtime | default('10m') }}
maxretry = {{ fail2ban_maxretry | default(5) }}
[sshd]
enabled = true
port = ssh
+2 -2
View File
@@ -1,7 +1,7 @@
# Git-over-ssh stays on the host sshd port 22 via passthrough
services:
db:
image: mariadb:11.8
image: mariadb:11.8.8
restart: unless-stopped
environment:
MARIADB_DATABASE: gitea
@@ -15,7 +15,7 @@ services:
interval: 10s
retries: 12
gitea:
image: docker.gitea.com/gitea:1.26.4
image: docker.gitea.com/gitea:1.27.1
restart: unless-stopped
depends_on:
db:
+51
View File
@@ -0,0 +1,51 @@
# Shared checkout of a gitea repo: root seeds and fast-forwards it over anonymous
# https, aurbis members push and pull over ssh with their own gitea key.
- name: Create {{ checkout_repo }} directory
file:
path: "{{ checkout_dest }}"
state: directory
owner: root
group: aurbis
mode: "02775"
- name: Seed {{ checkout_repo }}
ansible.builtin.git:
repo: "{{ gitea_https }}/{{ checkout_repo }}.git"
dest: "{{ checkout_dest }}"
version: "{{ checkout_version | default('master') }}"
update: false
force: false
- name: Point {{ checkout_repo }} origin at git-over-ssh
community.general.git_config:
name: remote.origin.url
scope: local
repo: "{{ checkout_dest }}"
value: "{{ gitea_ssh }}:{{ checkout_repo }}.git"
- name: Have git keep {{ checkout_repo }} group-writable
community.general.git_config:
name: core.sharedRepository
scope: local
repo: "{{ checkout_dest }}"
value: group
- name: Add {{ checkout_repo }} to safe.directory
community.general.git_config:
name: safe.directory
scope: system
add_mode: add
value: "{{ checkout_dest }}"
# ff-only, so unpushed commits or conflicting edits on the host fail the run instead of being lost.
- name: Fast-forward {{ checkout_repo }}
ansible.builtin.shell:
chdir: "{{ checkout_dest }}"
cmd: |
set -e
umask 002
before=$(git rev-parse HEAD)
git fetch -q {{ gitea_https }}/{{ checkout_repo }}.git +refs/heads/{{ checkout_version | default('master') }}:refs/remotes/origin/{{ checkout_version | default('master') }}
git merge -q --ff-only origin/{{ checkout_version | default('master') }}
[ "$before" = "$(git rev-parse HEAD)" ] || echo updated
register: checkout_pull
changed_when: "'updated' in checkout_pull.stdout"
when: checkout_update | default(true)
- import_tasks: aurbis_tree.yml
vars:
tree_path: "{{ checkout_dest }}"
+1 -1
View File
@@ -1,6 +1,6 @@
services:
db:
image: mariadb:11.8
image: mariadb:11.8.8
restart: unless-stopped
environment:
MARIADB_DATABASE: mediawikidb
+1 -1
View File
@@ -4,7 +4,7 @@
state: directory
owner: root
group: aurbis
mode: "0775"
mode: "02775"
- name: Create mosquitto config directory
file:
+1 -1
View File
@@ -1,6 +1,6 @@
services:
jellyfin:
image: jellyfin/jellyfin:10.11
image: jellyfin/jellyfin:12.0
container_name: jellyfin
# Optional - specify the uid and gid you would like Jellyfin to use instead of root
user: 0:1003
+4 -4
View File
@@ -1,6 +1,6 @@
services:
db:
image: mariadb:11.8
image: mariadb:11.8.8
restart: unless-stopped
command: --transaction-isolation=READ-COMMITTED
environment:
@@ -15,10 +15,10 @@ services:
interval: 10s
retries: 12
redis:
image: redis:alpine
image: redis:8.8.0-alpine
restart: unless-stopped
nextcloud:
image: nextcloud:34.0.1-apache
image: nextcloud:34.0.2-apache
restart: unless-stopped
depends_on:
db:
@@ -35,7 +35,7 @@ services:
TRUSTED_PROXIES: "172.16.0.0/12"
APACHE_DISABLE_REWRITE_IP: 1
cron:
image: nextcloud:34.0.1-apache
image: nextcloud:34.0.2-apache
restart: unless-stopped
entrypoint: /cron.sh
depends_on:
+14 -1
View File
@@ -4,7 +4,7 @@
state: directory
owner: root
group: aurbis
mode: "0775"
mode: "02775"
# Song library. Read-only for nightingale.
# Keep this in sync with the /karaoke mount in nextcloud
@@ -17,6 +17,19 @@
group: www-data
mode: "02775"
# Processed-song cache. Bind-mounted into the container at /data/cache and
# reachable over sshfs so songs can be analyzed on a machine with more RAM and
# the results dropped straight in here. Owned by the container's uid (999, fixed
# in razzaru/nightingale) so it can write as owner; group aurbis + setgid lets
# aurbis members (sshfs) create/replace files too.
- name: Create nightingale cache dir (shared with container uid 999 + aurbis)
file:
path: /opt/nightingale/cache
state: directory
owner: "999"
group: aurbis
mode: "02775"
- name: Template nightingale compose
template:
src: nightingale/docker-compose.yml.j2
+9 -1
View File
@@ -2,13 +2,21 @@
# CPU-only prebuilt image
services:
nightingale:
image: razzaru/nightingale:latest
image: razzaru/nightingale:1.2.0
restart: unless-stopped
ports:
- "127.0.0.1:8087:8080"
# Keeps separation resident but forces the alignment spike into swap rather
# than evicting the other stacks and hanging the host.
mem_limit: 9g
memswap_limit: 24g
# /data/cache is bind-mounted so it can be reached over sshfs and songs
# can be pre-processed on a machine with more RAM (see docs/aurbis.wiki).
# Everything else (db, models, vendor) stays in the named volume.
volumes:
- data:/data
- ./songs:/songs:ro
- ./cache:/data/cache
environment:
NIGHTINGALE_LIBRARY_PATH: /songs
+4 -15
View File
@@ -1,15 +1,4 @@
- name: Git clone
ansible.builtin.git:
repo: https://git.hoekveen.net/mark/scripts.git
dest: /opt/scripts
force: true
- name: Set permissions and ownership for scripts folder
file:
path: /opt/scripts
state: directory
recurse: true
group: aurbis
mode: "0775"
- name: Add scripts directory to safe.directory
ansible.builtin.command:
cmd: git config --system --add safe.directory /opt/scripts
- import_tasks: gitea_checkout.yml
vars:
checkout_repo: mark/scripts
checkout_dest: /opt/scripts
+11 -18
View File
@@ -1,31 +1,19 @@
# Pulling needs to have git access; root does not.
- name: Include stroopwafel vault
include_vars:
dir: stroopwafel
files_matching: vault.yml
- name: Create stroopwafel directory
file:
path: "{{ stroopwafel_dir }}"
state: directory
owner: root
group: "{{ service_group | default('aurbis') }}"
mode: "0775"
- name: Check out stroopwafel source
ansible.builtin.git:
repo: "{{ stroopwafel_repo }}"
dest: "{{ stroopwafel_dir }}"
version: "{{ stroopwafel_version }}"
update: "{{ stroopwafel_update | default(false) }}"
accept_hostkey: true
force: false
become_user: "{{ stroopwafel_git_user | default(omit) }}"
- import_tasks: gitea_checkout.yml
vars:
checkout_repo: "{{ stroopwafel_repo }}"
checkout_dest: "{{ stroopwafel_dir }}"
checkout_version: "{{ stroopwafel_version }}"
- name: Deploy stroopwafel .env
copy:
content: "{{ stroopwafel_env_b64 | b64decode }}"
dest: "{{ stroopwafel_dir }}/.env"
owner: root
group: "{{ service_group | default('aurbis') }}"
mode: "0640"
mode: "0660"
when: stroopwafel_env_b64 is defined
no_log: true
- name: Copy docker-compose file
@@ -39,3 +27,8 @@
community.docker.docker_compose_v2:
project_src: "{{ stroopwafel_dir }}"
build: policy
- name: Restart stroopwafel on new code
community.docker.docker_compose_v2:
project_src: "{{ stroopwafel_dir }}"
state: restarted
when: checkout_pull is changed
+46
View File
@@ -0,0 +1,46 @@
- name: Check swapfile
stat:
path: /swapfile
register: swapfile
- name: Size swapfile
when: not swapfile.stat.exists or swapfile.stat.size != swapfile_size_gb | int * 1024 * 1024 * 1024
block:
- name: Disable swapfile
command: swapoff /swapfile
when: swapfile.stat.exists
changed_when: true
- name: Remove old swapfile
file:
path: /swapfile
state: absent
- name: Allocate swapfile
command: fallocate -l {{ swapfile_size_gb }}G /swapfile
changed_when: true
- name: Format swapfile
command: mkswap /swapfile
changed_when: true
- name: Restrict swapfile permissions
file:
path: /swapfile
owner: root
group: root
mode: "0600"
- name: Persist swapfile in fstab
ansible.posix.mount:
src: /swapfile
path: none
fstype: swap
opts: sw
state: present
- name: Check active swap
command: swapon --show=NAME --noheadings
register: swapfile_active
changed_when: false
- name: Enable swapfile
command: swapon /swapfile
when: "'/swapfile' not in swapfile_active.stdout_lines"