diff --git a/playbook.yml b/playbook.yml index 04d5a0e..8ef94f2 100644 --- a/playbook.yml +++ b/playbook.yml @@ -129,6 +129,8 @@ tags: hdwiki - import_tasks: tasks/gitea.yml tags: gitea + - import_tasks: tasks/authentik.yml + tags: authentik - import_tasks: tasks/nightingale.yml tags: nightingale - import_tasks: tasks/stroopwafel.yml diff --git a/tasks/authentik.yml b/tasks/authentik.yml new file mode 100644 index 0000000..05a82de --- /dev/null +++ b/tasks/authentik.yml @@ -0,0 +1,22 @@ +- name: Include authentik vault + include_vars: + dir: authentik + files_matching: vault.yml +- name: Create authentik directory + file: + path: /opt/authentik + state: directory + owner: root + group: aurbis + mode: "02775" +- name: Template authentik env + template: + src: authentik/env.j2 + dest: /opt/authentik/.env + owner: root + group: aurbis + mode: "0660" +- name: Deploy authentik + include_tasks: tasks/docker_service.yml + vars: + service_name: authentik diff --git a/tasks/authentik/docker-compose.yml.j2 b/tasks/authentik/docker-compose.yml.j2 new file mode 100644 index 0000000..ae64228 --- /dev/null +++ b/tasks/authentik/docker-compose.yml.j2 @@ -0,0 +1,62 @@ +services: + postgresql: + image: docker.io/library/postgres:16-alpine + restart: unless-stopped + healthcheck: + test: ["CMD-SHELL", "pg_isready -d $${POSTGRES_DB} -U $${POSTGRES_USER}"] + start_period: 20s + interval: 30s + retries: 5 + timeout: 5s + volumes: + - database:/var/lib/postgresql/data + environment: + POSTGRES_USER: authentik + POSTGRES_DB: authentik + POSTGRES_PASSWORD: ${PG_PASS:?database password required} + env_file: + - .env + server: + image: ghcr.io/goauthentik/server:${AUTHENTIK_TAG} + restart: unless-stopped + command: server + environment: + AUTHENTIK_POSTGRESQL__HOST: postgresql + AUTHENTIK_POSTGRESQL__USER: authentik + AUTHENTIK_POSTGRESQL__NAME: authentik + AUTHENTIK_POSTGRESQL__PASSWORD: ${PG_PASS} + volumes: + - ./data/media:/data/media + - ./custom-templates:/templates + env_file: + - .env + ports: + - "127.0.0.1:9000:9000" + - "127.0.0.1:9443:9443" + depends_on: + postgresql: + condition: service_healthy + worker: + image: ghcr.io/goauthentik/server:${AUTHENTIK_TAG} + restart: unless-stopped + command: worker + environment: + AUTHENTIK_POSTGRESQL__HOST: postgresql + AUTHENTIK_POSTGRESQL__USER: authentik + AUTHENTIK_POSTGRESQL__NAME: authentik + AUTHENTIK_POSTGRESQL__PASSWORD: ${PG_PASS} + # Fixes ownership of the mounted dirs on start + user: root + volumes: + - ./data/media:/data/media + - ./certs:/certs + - ./custom-templates:/templates + env_file: + - .env + depends_on: + postgresql: + condition: service_healthy + +volumes: + database: + driver: local diff --git a/tasks/authentik/env.j2 b/tasks/authentik/env.j2 new file mode 100644 index 0000000..1cf1df0 --- /dev/null +++ b/tasks/authentik/env.j2 @@ -0,0 +1,14 @@ +AUTHENTIK_TAG=2026.8.5 + +PG_PASS={{ authentik_pg_password }} +AUTHENTIK_SECRET_KEY={{ authentik_secret_key }} +AUTHENTIK_ERROR_REPORTING__ENABLED=true + +AUTHENTIK_EMAIL__HOST=send.one.com +AUTHENTIK_EMAIL__PORT=465 +AUTHENTIK_EMAIL__USERNAME=authentik@hoekveen.net +AUTHENTIK_EMAIL__PASSWORD={{ authentik_email_password }} +AUTHENTIK_EMAIL__USE_TLS=false +AUTHENTIK_EMAIL__USE_SSL=true +AUTHENTIK_EMAIL__TIMEOUT=10 +AUTHENTIK_EMAIL__FROM=Hoekveen.net SSO diff --git a/tasks/authentik/vault.yml b/tasks/authentik/vault.yml new file mode 100644 index 0000000..645f135 --- /dev/null +++ b/tasks/authentik/vault.yml @@ -0,0 +1,14 @@ +$ANSIBLE_VAULT;1.1;AES256 +33373361623039323032623234343336313932303732656433383566633439356464653066363165 +3230316336373563313636306162343030643634363965300a663662353633666363666234613933 +64643034646534393131356637373930303266636361643565656239633863363366386331333461 +3338633433306336660a363036643538383763386331316362363730386439623836643536346462 +32393530376232663838653831373665356664373965396238363432313465613238613533326235 +61316630336535353538393261376533326132643765366463623830653065313033386438396338 +36643262373636343830376566633133393139633634393366643762393136316437663735623561 +63306130363731396432366539336661343061313466656138613465623234333464356431613563 +33396562366130633130646639373333616566613966373937613462316133373835333836346564 +63393634363064666230343432313366353263373862353036333038313035636365623361636331 +35653462303033613331336439666135386437363234376562366161626435303862343065613434 +36316266313838643361663762636339616166366561643262383437626339306362376635383166 +38333733326161616235326662373438343030303336666264623839386461306533