refactor: update authentik configuration and convert core_net dashboard template to static file
ansible-core-net / deploy (push) Successful in 25s
ansible-core-net / deploy (push) Successful in 25s
This commit is contained in:
1 parent
a243ae281c
commit
341538fba9
7 files changed
+40
-79
No files matched your search
@@ -5,11 +5,4 @@
|
|||||||
roles:
|
roles:
|
||||||
- core_net
|
- core_net
|
||||||
- authentik
|
- authentik
|
||||||
tasks:
|
|
||||||
- name: Закрыть панель Traefik через Authentik
|
|
||||||
ansible.builtin.template:
|
|
||||||
src: "{{ playbook_dir }}/../roles/core_net/templates/dynamic/dashboard.yml.j2"
|
|
||||||
dest: "{{ traefik_dynamic_dir }}/dashboard.yml"
|
|
||||||
owner: root
|
|
||||||
group: root
|
|
||||||
mode: "0644"
|
|
||||||
@@ -1,12 +1,15 @@
|
|||||||
# yaml-language-server: $schema=https://goauthentik.io/blueprints/schema.json
|
# yaml-language-server: $schema=https://goauthentik.io/blueprints/schema.json
|
||||||
# Панель Traefik. Список providers у встроенного outpost полный:
|
|
||||||
# следующий proxy-провайдер добавляется сюда же.
|
|
||||||
version: 1
|
version: 1
|
||||||
metadata:
|
metadata:
|
||||||
name: traefik-dashboard
|
name: traefik-dashboard
|
||||||
labels:
|
labels:
|
||||||
blueprints.goauthentik.io/description: "Панель Traefik только для группы admins"
|
blueprints.goauthentik.io/description: "Панель Traefik только для группы admins"
|
||||||
entries:
|
entries:
|
||||||
|
- model: authentik_core.group
|
||||||
|
id: group-admins
|
||||||
|
identifiers:
|
||||||
|
name: admins
|
||||||
|
|
||||||
- model: authentik_providers_proxy.proxyprovider
|
- model: authentik_providers_proxy.proxyprovider
|
||||||
id: provider-traefik-dashboard
|
id: provider-traefik-dashboard
|
||||||
identifiers:
|
identifiers:
|
||||||
@@ -32,11 +35,16 @@ entries:
|
|||||||
order: 0
|
order: 0
|
||||||
target: !KeyOf app-traefik-dashboard
|
target: !KeyOf app-traefik-dashboard
|
||||||
attrs:
|
attrs:
|
||||||
group: !Find [authentik_core.group, [name, admins]]
|
group: !KeyOf group-admins
|
||||||
|
|
||||||
- model: authentik_outposts.outpost
|
- model: authentik_outposts.outpost
|
||||||
identifiers:
|
identifiers:
|
||||||
name: authentik Embedded Outpost
|
name: authentik Embedded Outpost
|
||||||
attrs:
|
attrs:
|
||||||
|
type: proxy
|
||||||
|
service_connection: null
|
||||||
|
config:
|
||||||
|
authentik_host: https://auth.gunihome.ru
|
||||||
providers:
|
providers:
|
||||||
- !KeyOf provider-traefik-dashboard
|
- !KeyOf provider-traefik-dashboard
|
||||||
|
|
||||||
@@ -6,15 +6,13 @@
|
|||||||
owner: "{{ item.owner }}"
|
owner: "{{ item.owner }}"
|
||||||
group: "{{ item.group }}"
|
group: "{{ item.group }}"
|
||||||
mode: "{{ item.mode }}"
|
mode: "{{ item.mode }}"
|
||||||
recurse: "{{ item.recurse | default(false) }}"
|
|
||||||
loop:
|
loop:
|
||||||
- { path: "{{ authentik_dir }}", owner: "root", group: "root", mode: "0755" }
|
- { path: "{{ authentik_dir }}", owner: "root", group: "root", mode: "0755" }
|
||||||
- { path: "{{ authentik_dir }}/db", owner: "70", group: "70", mode: "0700", recurse: true }
|
- { path: "{{ authentik_dir }}/db", owner: "70", group: "70", mode: "0700" }
|
||||||
- { path: "{{ authentik_dir }}/redis", owner: "999", group: "999", mode: "0700", recurse: true }
|
- { path: "{{ authentik_dir }}/redis", owner: "999", group: "999", mode: "0700" }
|
||||||
- { path: "{{ authentik_dir }}/media", owner: "1000", group: "1000", mode: "0775", recurse: true }
|
- { path: "{{ authentik_dir }}/media", owner: "1000", group: "1000", mode: "0775" }
|
||||||
- { path: "{{ authentik_dir }}/custom-templates", owner: "1000", group: "1000", mode: "0775", recurse: true }
|
- { path: "{{ authentik_dir }}/custom-templates", owner: "1000", group: "1000", mode: "0775" }
|
||||||
- { path: "{{ authentik_dir }}/blueprints", owner: "root", group: "root", mode: "0755" }
|
- { path: "{{ authentik_dir }}/blueprints", owner: "root", group: "root", mode: "0755" }
|
||||||
register: authentik_dirs
|
|
||||||
|
|
||||||
- name: Проверить наличие обязательных секретов Authentik
|
- name: Проверить наличие обязательных секретов Authentik
|
||||||
ansible.builtin.assert:
|
ansible.builtin.assert:
|
||||||
@@ -32,7 +30,7 @@
|
|||||||
mode: "0600"
|
mode: "0600"
|
||||||
no_log: true
|
no_log: true
|
||||||
|
|
||||||
- name: Установить blueprint каталога пользователей Authentik
|
- name: Синхронизировать blueprints Authentik
|
||||||
ansible.builtin.copy:
|
ansible.builtin.copy:
|
||||||
src: blueprints/
|
src: blueprints/
|
||||||
dest: "{{ authentik_dir }}/blueprints/"
|
dest: "{{ authentik_dir }}/blueprints/"
|
||||||
@@ -46,44 +44,9 @@
|
|||||||
register: compose_up
|
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"
|
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 при изменении прав
|
- name: Перезапустить воркер Authentik при обновлении blueprints
|
||||||
ansible.builtin.command: docker compose -f {{ authentik_dir }}/compose.yaml restart authentik-db authentik-server
|
ansible.builtin.command: docker compose -f {{ authentik_dir }}/compose.yaml restart authentik-worker
|
||||||
when: authentik_dirs.changed
|
when: authentik_blueprint.changed and not compose_up.changed
|
||||||
|
|
||||||
- name: Применить blueprint каталога пользователей Authentik
|
|
||||||
ansible.builtin.command: >-
|
|
||||||
docker compose -f {{ authentik_dir }}/compose.yaml exec -T authentik-worker
|
|
||||||
ak apply_blueprint
|
|
||||||
/blueprints/custom/homelab-directory.yaml
|
|
||||||
/blueprints/custom/traefik-dashboard.yaml
|
|
||||||
register: authentik_blueprint_apply
|
|
||||||
changed_when: authentik_blueprint.changed
|
|
||||||
retries: 18
|
|
||||||
delay: 10
|
|
||||||
until: authentik_blueprint_apply.rc == 0
|
|
||||||
|
|
||||||
- name: Обновить права сервисного аккаунта встроенного outpost
|
|
||||||
ansible.builtin.command:
|
|
||||||
argv:
|
|
||||||
- docker
|
|
||||||
- compose
|
|
||||||
- -f
|
|
||||||
- "{{ authentik_dir }}/compose.yaml"
|
|
||||||
- exec
|
|
||||||
- -T
|
|
||||||
- authentik-worker
|
|
||||||
- ak
|
|
||||||
- shell
|
|
||||||
- -c
|
|
||||||
- >-
|
|
||||||
from authentik.outposts.models import Outpost;
|
|
||||||
from authentik.outposts.tasks import _outpost_single_update;
|
|
||||||
outpost = Outpost.objects.get(name="authentik Embedded Outpost");
|
|
||||||
_outpost_single_update(outpost)
|
|
||||||
register: authentik_outpost_perms
|
|
||||||
changed_when: true
|
|
||||||
retries: 6
|
|
||||||
delay: 5
|
|
||||||
until: authentik_outpost_perms.rc == 0
|
|
||||||
|
|
||||||
|
|
||||||
@@ -43,6 +43,10 @@ services:
|
|||||||
AUTHENTIK_POSTGRESQL__NAME: authentik
|
AUTHENTIK_POSTGRESQL__NAME: authentik
|
||||||
AUTHENTIK_POSTGRESQL__PASSWORD: {{ authentik_postgres_password }}
|
AUTHENTIK_POSTGRESQL__PASSWORD: {{ authentik_postgres_password }}
|
||||||
AUTHENTIK_SECRET_KEY: {{ authentik_secret_key }}
|
AUTHENTIK_SECRET_KEY: {{ authentik_secret_key }}
|
||||||
|
AUTHENTIK_DISABLE_UPDATE_CHECK: "true"
|
||||||
|
AUTHENTIK_DISABLE_STARTUP_ANALYTICS: "true"
|
||||||
|
AUTHENTIK_ERROR_REPORTING__ENABLED: "false"
|
||||||
|
AUTHENTIK_OUTPOSTS__DISCOVER: "false"
|
||||||
volumes:
|
volumes:
|
||||||
- {{ authentik_dir }}/media:/media
|
- {{ authentik_dir }}/media:/media
|
||||||
- {{ authentik_dir }}/custom-templates:/templates
|
- {{ authentik_dir }}/custom-templates:/templates
|
||||||
@@ -69,9 +73,11 @@ services:
|
|||||||
AUTHENTIK_POSTGRESQL__NAME: authentik
|
AUTHENTIK_POSTGRESQL__NAME: authentik
|
||||||
AUTHENTIK_POSTGRESQL__PASSWORD: {{ authentik_postgres_password }}
|
AUTHENTIK_POSTGRESQL__PASSWORD: {{ authentik_postgres_password }}
|
||||||
AUTHENTIK_SECRET_KEY: {{ authentik_secret_key }}
|
AUTHENTIK_SECRET_KEY: {{ authentik_secret_key }}
|
||||||
user: root
|
AUTHENTIK_DISABLE_UPDATE_CHECK: "true"
|
||||||
|
AUTHENTIK_DISABLE_STARTUP_ANALYTICS: "true"
|
||||||
|
AUTHENTIK_ERROR_REPORTING__ENABLED: "false"
|
||||||
|
AUTHENTIK_OUTPOSTS__DISCOVER: "false"
|
||||||
volumes:
|
volumes:
|
||||||
- /var/run/docker.sock:/var/run/docker.sock
|
|
||||||
- {{ authentik_dir }}/media:/media
|
- {{ authentik_dir }}/media:/media
|
||||||
- {{ authentik_dir }}/custom-templates:/templates
|
- {{ authentik_dir }}/custom-templates:/templates
|
||||||
- {{ authentik_dir }}/blueprints:/blueprints/custom:ro
|
- {{ authentik_dir }}/blueprints:/blueprints/custom:ro
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
http:
|
||||||
|
routers:
|
||||||
|
traefik-dashboard:
|
||||||
|
rule: "Host(`proxy.gunihome.ru`)"
|
||||||
|
entryPoints:
|
||||||
|
- websecure
|
||||||
|
service: api@internal
|
||||||
|
middlewares:
|
||||||
|
- authentik@file
|
||||||
|
tls:
|
||||||
|
certResolver: letsencrypt
|
||||||
@@ -80,7 +80,7 @@
|
|||||||
state: absent
|
state: absent
|
||||||
loop: "{{ remote_dynamic_files.files }}"
|
loop: "{{ remote_dynamic_files.files }}"
|
||||||
vars:
|
vars:
|
||||||
repo_files: "{{ (q('fileglob', role_path ~ '/files/dynamic/*.yml') | map('basename') | list) + ['dashboard.yml'] }}"
|
repo_files: "{{ q('fileglob', role_path ~ '/files/dynamic/*.yml') | map('basename') | list }}"
|
||||||
when: item.path | basename not in repo_files
|
when: item.path | basename not in repo_files
|
||||||
|
|
||||||
- name: Запустить Traefik через Docker Compose
|
- name: Запустить Traefik через Docker Compose
|
||||||
|
|||||||
@@ -1,20 +0,0 @@
|
|||||||
http:
|
|
||||||
routers:
|
|
||||||
traefik-dashboard:
|
|
||||||
rule: "Host(`proxy.gunihome.ru`)"
|
|
||||||
priority: 1
|
|
||||||
entryPoints:
|
|
||||||
- websecure
|
|
||||||
service: api@internal
|
|
||||||
middlewares:
|
|
||||||
- authentik@file
|
|
||||||
tls:
|
|
||||||
certResolver: letsencrypt
|
|
||||||
traefik-dashboard-outpost:
|
|
||||||
rule: "Host(`proxy.gunihome.ru`) && PathPrefix(`/outpost.goauthentik.io`)"
|
|
||||||
priority: 100
|
|
||||||
entryPoints:
|
|
||||||
- websecure
|
|
||||||
service: authentik@file
|
|
||||||
tls:
|
|
||||||
certResolver: letsencrypt
|
|
||||||
Reference in new issue
Block a user