refactor(auth): remove Authentik SSO, restore basic auth and provision Node Exporter dashboard
ansible-core-mon / deploy (push) Successful in 25s
ansible-core-net / deploy (push) Failing after 25s
ansible-core-secrets / deploy (push) Successful in 12s
ansible-opnsense / deploy (push) Successful in 5s
ansible-rus-central / deploy (push) Successful in 37s
ansible-core-mon / deploy (push) Successful in 25s
ansible-core-net / deploy (push) Failing after 25s
ansible-core-secrets / deploy (push) Successful in 12s
ansible-opnsense / deploy (push) Successful in 5s
ansible-rus-central / deploy (push) Successful in 37s
This commit is contained in:
1 parent
94a143623b
commit
c0a9d7f0c8
16 files changed
+15726
-263
No files matched your search
@@ -1,8 +1,8 @@
|
||||
---
|
||||
authentik_version: "2024.12.3"
|
||||
authentik_dir: "/opt/authentik"
|
||||
authentik_enabled: false
|
||||
authentik_http_port: 9000
|
||||
authentik_secret_key: "{{ lookup('env', 'AUTHENTIK_SECRET_KEY') }}"
|
||||
authentik_postgres_password: "{{ lookup('env', 'AUTHENTIK_POSTGRES_PASSWORD') }}"
|
||||
grafana_oauth_client_secret: "{{ lookup('env', 'GRAFANA_OAUTH_CLIENT_SECRET') }}"
|
||||
|
||||
@@ -3,18 +3,13 @@ version: 1
|
||||
metadata:
|
||||
name: traefik-dashboard
|
||||
labels:
|
||||
blueprints.goauthentik.io/description: "Панель Traefik и Ntfy Forward-auth"
|
||||
blueprints.goauthentik.io/description: "Панель Traefik только для группы admins"
|
||||
entries:
|
||||
- model: authentik_core.group
|
||||
id: group-admins
|
||||
identifiers:
|
||||
name: admins
|
||||
|
||||
- model: authentik_core.group
|
||||
id: group-family
|
||||
identifiers:
|
||||
name: family
|
||||
|
||||
- model: authentik_providers_proxy.proxyprovider
|
||||
id: provider-traefik-dashboard
|
||||
identifiers:
|
||||
@@ -42,43 +37,6 @@ entries:
|
||||
attrs:
|
||||
group: !KeyOf group-admins
|
||||
|
||||
- model: authentik_providers_proxy.proxyprovider
|
||||
id: provider-ntfy
|
||||
identifiers:
|
||||
name: ntfy
|
||||
attrs:
|
||||
mode: forward_single
|
||||
external_host: https://ntfy.gunihome.ru
|
||||
intercept_header_auth: true
|
||||
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-ntfy
|
||||
identifiers:
|
||||
slug: ntfy
|
||||
attrs:
|
||||
name: Ntfy
|
||||
meta_launch_url: https://ntfy.gunihome.ru
|
||||
policy_engine_mode: any
|
||||
provider: !KeyOf provider-ntfy
|
||||
|
||||
- model: authentik_policies.policybinding
|
||||
identifiers:
|
||||
order: 0
|
||||
target: !KeyOf app-ntfy
|
||||
attrs:
|
||||
group: !KeyOf group-admins
|
||||
|
||||
- model: authentik_policies.policybinding
|
||||
identifiers:
|
||||
order: 1
|
||||
target: !KeyOf app-ntfy
|
||||
attrs:
|
||||
group: !KeyOf group-family
|
||||
|
||||
# providers ниже — полный список embedded outpost.
|
||||
# Новый proxy-провайдер добавляется в этот файл, а не только в интерфейсе.
|
||||
- model: authentik_outposts.outpost
|
||||
identifiers:
|
||||
name: authentik Embedded Outpost
|
||||
@@ -89,4 +47,3 @@ entries:
|
||||
authentik_host: https://auth.gunihome.ru
|
||||
providers:
|
||||
- !KeyOf provider-traefik-dashboard
|
||||
- !KeyOf provider-ntfy
|
||||
@@ -1,71 +1,75 @@
|
||||
---
|
||||
- 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 если сервис отключен
|
||||
when: not authentik_enabled
|
||||
block:
|
||||
- name: Проверить наличие compose.yaml для Authentik
|
||||
ansible.builtin.stat:
|
||||
path: "{{ authentik_dir }}/compose.yaml"
|
||||
register: authentik_compose_stat
|
||||
|
||||
- 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
|
||||
- grafana_oauth_client_secret is defined and grafana_oauth_client_secret | length > 0
|
||||
fail_msg: "Один или несколько секретов Authentik (AUTHENTIK_SECRET_KEY, AUTHENTIK_POSTGRES_PASSWORD, GRAFANA_OAUTH_CLIENT_SECRET) не переданы!"
|
||||
- name: Остановить контейнеры Authentik
|
||||
ansible.builtin.command: docker compose -f {{ authentik_dir }}/compose.yaml stop
|
||||
when: authentik_compose_stat.stat.exists
|
||||
register: compose_stop
|
||||
changed_when: "'Stopping' in compose_stop.stderr or 'Stopped' in compose_stop.stderr"
|
||||
failed_when: false
|
||||
|
||||
- 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: Управление сервисом Authentik
|
||||
when: authentik_enabled
|
||||
block:
|
||||
- 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: Синхронизировать статические blueprints Authentik
|
||||
ansible.builtin.copy:
|
||||
src: blueprints/
|
||||
dest: "{{ authentik_dir }}/blueprints/"
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0644"
|
||||
register: authentik_blueprint
|
||||
- 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: Установить шаблонные blueprints Authentik
|
||||
ansible.builtin.template:
|
||||
src: blueprints/grafana.yaml.j2
|
||||
dest: "{{ authentik_dir }}/blueprints/grafana.yaml"
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0644"
|
||||
register: authentik_blueprint_grafana
|
||||
no_log: true
|
||||
- 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: Запустить сервисы 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 or authentik_blueprint_grafana.changed) and not compose_up.changed
|
||||
|
||||
- name: Применить blueprints Authentik в authentik-server
|
||||
ansible.builtin.command: >
|
||||
docker compose -f {{ authentik_dir }}/compose.yaml exec -T authentik-server
|
||||
ak apply_blueprint /blueprints/custom/traefik-dashboard.yaml /blueprints/custom/grafana.yaml
|
||||
when: authentik_blueprint.changed or authentik_blueprint_grafana.changed or compose_up.changed
|
||||
register: apply_blueprints_cmd
|
||||
changed_when: 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
|
||||
|
||||
- name: Применить blueprints Authentik в authentik-server
|
||||
ansible.builtin.command: >
|
||||
docker compose -f {{ authentik_dir }}/compose.yaml exec -T authentik-server
|
||||
ak apply_blueprint /blueprints/custom/traefik-dashboard.yaml
|
||||
when: authentik_blueprint.changed or compose_up.changed
|
||||
register: apply_blueprints_cmd
|
||||
changed_when: true
|
||||
@@ -1,73 +0,0 @@
|
||||
# yaml-language-server: $schema=https://goauthentik.io/blueprints/schema.json
|
||||
version: 1
|
||||
metadata:
|
||||
name: grafana-sso
|
||||
labels:
|
||||
blueprints.goauthentik.io/description: "Grafana OAuth2 Provider"
|
||||
entries:
|
||||
- model: authentik_core.group
|
||||
id: group-admins
|
||||
identifiers:
|
||||
name: admins
|
||||
|
||||
- model: authentik_core.group
|
||||
id: group-family
|
||||
identifiers:
|
||||
name: family
|
||||
|
||||
- model: authentik_providers_oauth2.scopemapping
|
||||
id: scope-grafana-email
|
||||
identifiers:
|
||||
managed: homelab/providers/oauth2/scope-grafana-email
|
||||
attrs:
|
||||
name: "Grafana OAuth Mapping: OpenID 'email' with fallback"
|
||||
scope_name: email
|
||||
description: "Email scope with fallback for users without email"
|
||||
expression: |
|
||||
return {
|
||||
"email": request.user.email or f"{request.user.username}@gunihome.ru",
|
||||
"email_verified": True
|
||||
}
|
||||
|
||||
- model: authentik_providers_oauth2.oauth2provider
|
||||
id: provider-grafana
|
||||
identifiers:
|
||||
name: grafana
|
||||
attrs:
|
||||
client_type: confidential
|
||||
client_id: grafana
|
||||
client_secret: {{ grafana_oauth_client_secret | to_json }}
|
||||
redirect_uris:
|
||||
- matching_mode: strict
|
||||
url: https://graf.gunihome.ru/login/generic_oauth
|
||||
authorization_flow: !Find [authentik_flows.flow, [slug, default-provider-authorization-implicit-consent]]
|
||||
invalidation_flow: !Find [authentik_flows.flow, [slug, default-provider-invalidation-flow]]
|
||||
signing_key: !Find [authentik_crypto.certificatekeypair, [name, "authentik Self-signed Certificate"]]
|
||||
property_mappings:
|
||||
- !Find [authentik_providers_oauth2.scopemapping, [scope_name, openid]]
|
||||
- !KeyOf scope-grafana-email
|
||||
- !Find [authentik_providers_oauth2.scopemapping, [scope_name, profile]]
|
||||
|
||||
- model: authentik_core.application
|
||||
id: app-grafana
|
||||
identifiers:
|
||||
slug: grafana
|
||||
attrs:
|
||||
name: Grafana
|
||||
meta_launch_url: https://graf.gunihome.ru
|
||||
policy_engine_mode: any
|
||||
provider: !KeyOf provider-grafana
|
||||
|
||||
- model: authentik_policies.policybinding
|
||||
identifiers:
|
||||
order: 0
|
||||
target: !KeyOf app-grafana
|
||||
attrs:
|
||||
group: !KeyOf group-admins
|
||||
|
||||
- model: authentik_policies.policybinding
|
||||
identifiers:
|
||||
order: 1
|
||||
target: !KeyOf app-grafana
|
||||
attrs:
|
||||
group: !KeyOf group-family
|
||||
Reference in new issue
Block a user