refactor: split machine deploys from one-time secrets migration
Roles stay under the machine that runs them, CI applies only a known product, and the /opt/secrets move is a one-shot playbook instead of part of every core-secrets run. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
341538fba9
commit
9c692522fb
85 files changed
+537
-492
No files matched your search
@@ -0,0 +1,7 @@
|
||||
---
|
||||
authentik_version: "2024.12.3"
|
||||
authentik_dir: "/opt/authentik"
|
||||
authentik_http_port: 9000
|
||||
authentik_secret_key: "{{ lookup('env', 'AUTHENTIK_SECRET_KEY') }}"
|
||||
authentik_postgres_password: "{{ lookup('env', 'AUTHENTIK_POSTGRES_PASSWORD') }}"
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
# yaml-language-server: $schema=https://goauthentik.io/blueprints/schema.json
|
||||
# Каталог пользователей. Пароли не задаются: их выставляет суперадмин в интерфейсе.
|
||||
version: 1
|
||||
metadata:
|
||||
name: homelab-directory
|
||||
labels:
|
||||
blueprints.goauthentik.io/description: "Группы admins и family"
|
||||
entries:
|
||||
- model: authentik_core.group
|
||||
id: admins
|
||||
identifiers:
|
||||
name: admins
|
||||
|
||||
- model: authentik_core.group
|
||||
id: family
|
||||
identifiers:
|
||||
name: family
|
||||
|
||||
- model: authentik_core.user
|
||||
identifiers:
|
||||
username: karpenok
|
||||
attrs:
|
||||
name: karpenok
|
||||
is_active: true
|
||||
is_superuser: true
|
||||
groups:
|
||||
- !Find [authentik_core.group, [name, "authentik Admins"]]
|
||||
- !KeyOf admins
|
||||
- !KeyOf family
|
||||
|
||||
- model: authentik_core.user
|
||||
identifiers:
|
||||
username: ksynia
|
||||
attrs:
|
||||
name: ksynia
|
||||
is_active: true
|
||||
is_superuser: false
|
||||
groups:
|
||||
- !KeyOf family
|
||||
@@ -0,0 +1,52 @@
|
||||
# yaml-language-server: $schema=https://goauthentik.io/blueprints/schema.json
|
||||
version: 1
|
||||
metadata:
|
||||
name: traefik-dashboard
|
||||
labels:
|
||||
blueprints.goauthentik.io/description: "Панель Traefik только для группы admins"
|
||||
entries:
|
||||
- model: authentik_core.group
|
||||
id: group-admins
|
||||
identifiers:
|
||||
name: admins
|
||||
|
||||
- model: authentik_providers_proxy.proxyprovider
|
||||
id: provider-traefik-dashboard
|
||||
identifiers:
|
||||
name: traefik-dashboard
|
||||
attrs:
|
||||
mode: forward_single
|
||||
external_host: https://proxy.gunihome.ru
|
||||
authorization_flow: !Find [authentik_flows.flow, [slug, default-provider-authorization-implicit-consent]]
|
||||
invalidation_flow: !Find [authentik_flows.flow, [slug, default-provider-invalidation-flow]]
|
||||
|
||||
- model: authentik_core.application
|
||||
id: app-traefik-dashboard
|
||||
identifiers:
|
||||
slug: traefik-dashboard
|
||||
attrs:
|
||||
name: Traefik
|
||||
meta_launch_url: https://proxy.gunihome.ru
|
||||
policy_engine_mode: any
|
||||
provider: !KeyOf provider-traefik-dashboard
|
||||
|
||||
- model: authentik_policies.policybinding
|
||||
identifiers:
|
||||
order: 0
|
||||
target: !KeyOf app-traefik-dashboard
|
||||
attrs:
|
||||
group: !KeyOf group-admins
|
||||
|
||||
# providers ниже — полный список embedded outpost.
|
||||
# Новый proxy-провайдер добавляется в этот файл, а не только в интерфейсе.
|
||||
- model: authentik_outposts.outpost
|
||||
identifiers:
|
||||
name: authentik Embedded Outpost
|
||||
attrs:
|
||||
type: proxy
|
||||
service_connection: null
|
||||
config:
|
||||
authentik_host: https://auth.gunihome.ru
|
||||
providers:
|
||||
- !KeyOf provider-traefik-dashboard
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
---
|
||||
- name: Создать каталоги для сервиса Authentik с корректными правами
|
||||
ansible.builtin.file:
|
||||
path: "{{ item.path }}"
|
||||
state: directory
|
||||
owner: "{{ item.owner }}"
|
||||
group: "{{ item.group }}"
|
||||
mode: "{{ item.mode }}"
|
||||
loop:
|
||||
- { path: "{{ authentik_dir }}", owner: "root", group: "root", mode: "0755" }
|
||||
- { path: "{{ authentik_dir }}/db", owner: "70", group: "70", mode: "0700" }
|
||||
- { path: "{{ authentik_dir }}/redis", owner: "999", group: "999", mode: "0700" }
|
||||
- { path: "{{ authentik_dir }}/media", owner: "1000", group: "1000", mode: "0775" }
|
||||
- { path: "{{ authentik_dir }}/custom-templates", owner: "1000", group: "1000", mode: "0775" }
|
||||
- { path: "{{ authentik_dir }}/blueprints", owner: "root", group: "root", mode: "0755" }
|
||||
|
||||
- name: Проверить наличие обязательных секретов Authentik
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- authentik_secret_key is defined and authentik_secret_key | length > 0
|
||||
- authentik_postgres_password is defined and authentik_postgres_password | length > 0
|
||||
fail_msg: "Один или оба секрета Authentik (AUTHENTIK_SECRET_KEY, AUTHENTIK_POSTGRES_PASSWORD) не переданы через переменные окружения!"
|
||||
|
||||
- name: Установить compose.yaml для Authentik
|
||||
ansible.builtin.template:
|
||||
src: compose.yaml.j2
|
||||
dest: "{{ authentik_dir }}/compose.yaml"
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0600"
|
||||
no_log: true
|
||||
|
||||
- name: Синхронизировать blueprints Authentik
|
||||
ansible.builtin.copy:
|
||||
src: blueprints/
|
||||
dest: "{{ authentik_dir }}/blueprints/"
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0644"
|
||||
register: authentik_blueprint
|
||||
|
||||
- name: Запустить сервисы Authentik через Docker Compose
|
||||
ansible.builtin.command: docker compose -f {{ authentik_dir }}/compose.yaml up -d --remove-orphans
|
||||
register: compose_up
|
||||
changed_when: "'Started' in compose_up.stderr or 'Created' in compose_up.stderr or 'Recreated' in compose_up.stderr or 'Pulled' in compose_up.stderr"
|
||||
|
||||
- name: Перезапустить воркер Authentik при обновлении blueprints
|
||||
ansible.builtin.command: docker compose -f {{ authentik_dir }}/compose.yaml restart authentik-worker
|
||||
when: authentik_blueprint.changed and not compose_up.changed
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
services:
|
||||
authentik-db:
|
||||
image: postgres:16-alpine
|
||||
container_name: authentik-db
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
POSTGRES_PASSWORD: {{ authentik_postgres_password | to_json }}
|
||||
POSTGRES_USER: authentik
|
||||
POSTGRES_DB: authentik
|
||||
volumes:
|
||||
- {{ authentik_dir }}/db:/var/lib/postgresql/data
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready -d authentik -U authentik"]
|
||||
interval: 5s
|
||||
timeout: 5s
|
||||
retries: 10
|
||||
networks:
|
||||
- authentik-net
|
||||
|
||||
authentik-redis:
|
||||
image: redis:7-alpine
|
||||
container_name: authentik-redis
|
||||
restart: unless-stopped
|
||||
volumes:
|
||||
- {{ authentik_dir }}/redis:/data
|
||||
healthcheck:
|
||||
test: ["CMD", "redis-cli", "ping"]
|
||||
interval: 5s
|
||||
timeout: 5s
|
||||
retries: 10
|
||||
networks:
|
||||
- authentik-net
|
||||
|
||||
authentik-server:
|
||||
image: ghcr.io/goauthentik/server:{{ authentik_version }}
|
||||
container_name: authentik-server
|
||||
restart: unless-stopped
|
||||
command: server
|
||||
environment:
|
||||
AUTHENTIK_REDIS__HOST: authentik-redis
|
||||
AUTHENTIK_POSTGRESQL__HOST: authentik-db
|
||||
AUTHENTIK_POSTGRESQL__USER: authentik
|
||||
AUTHENTIK_POSTGRESQL__NAME: authentik
|
||||
AUTHENTIK_POSTGRESQL__PASSWORD: {{ authentik_postgres_password | to_json }}
|
||||
AUTHENTIK_SECRET_KEY: {{ authentik_secret_key | to_json }}
|
||||
AUTHENTIK_DISABLE_UPDATE_CHECK: "true"
|
||||
AUTHENTIK_DISABLE_STARTUP_ANALYTICS: "true"
|
||||
AUTHENTIK_ERROR_REPORTING__ENABLED: "false"
|
||||
AUTHENTIK_OUTPOSTS__DISCOVER: "false"
|
||||
volumes:
|
||||
- {{ authentik_dir }}/media:/media
|
||||
- {{ authentik_dir }}/custom-templates:/templates
|
||||
- {{ authentik_dir }}/blueprints:/blueprints/custom:ro
|
||||
ports:
|
||||
- "127.0.0.1:{{ authentik_http_port }}:9000"
|
||||
depends_on:
|
||||
authentik-db:
|
||||
condition: service_healthy
|
||||
authentik-redis:
|
||||
condition: service_healthy
|
||||
networks:
|
||||
- authentik-net
|
||||
|
||||
authentik-worker:
|
||||
image: ghcr.io/goauthentik/server:{{ authentik_version }}
|
||||
container_name: authentik-worker
|
||||
restart: unless-stopped
|
||||
command: worker
|
||||
environment:
|
||||
AUTHENTIK_REDIS__HOST: authentik-redis
|
||||
AUTHENTIK_POSTGRESQL__HOST: authentik-db
|
||||
AUTHENTIK_POSTGRESQL__USER: authentik
|
||||
AUTHENTIK_POSTGRESQL__NAME: authentik
|
||||
AUTHENTIK_POSTGRESQL__PASSWORD: {{ authentik_postgres_password | to_json }}
|
||||
AUTHENTIK_SECRET_KEY: {{ authentik_secret_key | to_json }}
|
||||
AUTHENTIK_DISABLE_UPDATE_CHECK: "true"
|
||||
AUTHENTIK_DISABLE_STARTUP_ANALYTICS: "true"
|
||||
AUTHENTIK_ERROR_REPORTING__ENABLED: "false"
|
||||
AUTHENTIK_OUTPOSTS__DISCOVER: "false"
|
||||
volumes:
|
||||
- {{ authentik_dir }}/media:/media
|
||||
- {{ authentik_dir }}/custom-templates:/templates
|
||||
- {{ authentik_dir }}/blueprints:/blueprints/custom:ro
|
||||
depends_on:
|
||||
authentik-db:
|
||||
condition: service_healthy
|
||||
authentik-redis:
|
||||
condition: service_healthy
|
||||
networks:
|
||||
- authentik-net
|
||||
|
||||
networks:
|
||||
authentik-net:
|
||||
name: authentik-net
|
||||
driver: bridge
|
||||
|
||||
Reference in new issue
Block a user