Switching over to using unix sockets for ICP
This commit is contained in:
@@ -46,7 +46,7 @@ caddy_sites_enabled_dir: "/etc/caddy/sites-enabled"
|
||||
|
||||
# Authentik manages its own database
|
||||
authentik_db_engine: "postgresql"
|
||||
authentik_db_host: "host.containers.internal"
|
||||
authentik_db_host: "/run/postgresql" # Unix socket directory
|
||||
authentik_db_port: 5432
|
||||
authentik_db_name: "authentik"
|
||||
authentik_db_user: "authentik"
|
||||
@@ -56,11 +56,11 @@ authentik_db_password: "{{ vault_authentik_db_password }}"
|
||||
# Cache Configuration (Valkey/Redis)
|
||||
# =================================================================
|
||||
|
||||
# Valkey/Redis cache configuration
|
||||
authentik_redis_host: "host.containers.internal"
|
||||
# Valkey/Redis cache configuration (TCP via host gateway)
|
||||
authentik_redis_host: "host.containers.internal" # Using TCP due to Authentik Unix socket issues
|
||||
authentik_redis_port: 6379
|
||||
authentik_redis_db: 1
|
||||
authentik_redis_password: "" # Valkey has no auth by default
|
||||
authentik_redis_password: "{{ vault_valkey_password | default('') }}"
|
||||
|
||||
# =================================================================
|
||||
# Application Settings
|
||||
@@ -104,4 +104,4 @@ authentik_enable_host_gateway: true
|
||||
# - Uses Valkey database 1 for caching
|
||||
# - Deploys Caddy configuration to sites-enabled
|
||||
# - Uses Podman quadlets for systemd integration
|
||||
# - Follows containerized service pattern with service-specific user
|
||||
# - Follows containerized service pattern with service-specific user
|
||||
|
||||
@@ -9,6 +9,10 @@ After=network-online.target
|
||||
[Pod]
|
||||
PodName={{ authentik_pod_name }}
|
||||
Network={{ authentik_network_name }}
|
||||
|
||||
# Mount Unix socket for PostgreSQL (Valkey uses TCP via host.containers.internal)
|
||||
Volume=/run/postgresql:/run/postgresql:ro
|
||||
# Host gateway allows access to localhost services
|
||||
{% if authentik_enable_host_gateway | default(true) %}
|
||||
AddHost=host.containers.internal:host-gateway
|
||||
{% endif %}
|
||||
@@ -18,4 +22,4 @@ PublishPort={{ authentik_http_port }}:9000
|
||||
PublishPort={{ authentik_https_port }}:9443
|
||||
|
||||
[Install]
|
||||
WantedBy=default.target
|
||||
WantedBy=default.target
|
||||
|
||||
@@ -38,9 +38,9 @@ caddy_sites_enabled_dir: "/etc/caddy/sites-enabled"
|
||||
# Database Configuration (Self-Contained)
|
||||
# =================================================================
|
||||
|
||||
# Gitea manages its own database
|
||||
# Gitea manages its own database (Unix socket connection)
|
||||
gitea_db_type: "postgres"
|
||||
gitea_db_host: "127.0.0.1"
|
||||
gitea_db_host: "/run/postgresql" # Unix socket directory
|
||||
gitea_db_port: 5432
|
||||
gitea_db_name: "gitea"
|
||||
gitea_db_user: "gitea"
|
||||
|
||||
@@ -24,7 +24,13 @@ APP_DATA_PATH = {{ gitea_home }}/data
|
||||
|
||||
[database]
|
||||
DB_TYPE = {{ gitea_db_type }}
|
||||
{% if gitea_db_host.startswith('/') %}
|
||||
# Unix socket connection
|
||||
HOST = {{ gitea_db_host }}
|
||||
{% else %}
|
||||
# TCP connection
|
||||
HOST = {{ gitea_db_host }}:{{ gitea_db_port }}
|
||||
{% endif %}
|
||||
NAME = {{ gitea_db_name }}
|
||||
USER = {{ gitea_db_user }}
|
||||
PASSWD = {{ gitea_db_password }}
|
||||
|
||||
@@ -13,10 +13,14 @@
|
||||
postgresql_service_enabled: true
|
||||
postgresql_service_state: "started"
|
||||
|
||||
# Network Security (localhost only)
|
||||
postgresql_listen_addresses: "localhost"
|
||||
# Network Security (Unix socket only - no network listening)
|
||||
postgresql_listen_addresses: "" # Empty string = no TCP/IP connections
|
||||
postgresql_port: 5432
|
||||
|
||||
# Unix socket configuration
|
||||
postgresql_unix_socket_directories: "/run/postgresql"
|
||||
postgresql_unix_socket_permissions: 0777 # Allows container access
|
||||
|
||||
# Authentication
|
||||
postgresql_auth_method: "scram-sha-256"
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
--auth-local=peer
|
||||
--auth-host={{ postgresql_auth_method }}
|
||||
{{ '--data-checksums' if postgresql_data_checksums else '' }}
|
||||
become: yes
|
||||
become: true
|
||||
become_user: postgres
|
||||
when: not postgresql_initialized.stat.exists
|
||||
notify: restart postgresql
|
||||
@@ -74,19 +74,29 @@
|
||||
state: "{{ postgresql_service_state }}"
|
||||
daemon_reload: yes
|
||||
|
||||
- name: Wait for PostgreSQL to be ready
|
||||
- name: Wait for PostgreSQL Unix socket to be ready
|
||||
wait_for:
|
||||
path: "{{ postgresql_unix_socket_directories }}/.s.PGSQL.{{ postgresql_port }}"
|
||||
timeout: 30
|
||||
when:
|
||||
- postgresql_service_state == "started"
|
||||
- postgresql_listen_addresses == "" # Socket-only mode
|
||||
|
||||
- name: Wait for PostgreSQL TCP to be ready
|
||||
wait_for:
|
||||
port: "{{ postgresql_port }}"
|
||||
host: "{{ postgresql_listen_addresses }}"
|
||||
timeout: 30
|
||||
when: postgresql_service_state == "started"
|
||||
when:
|
||||
- postgresql_service_state == "started"
|
||||
- postgresql_listen_addresses != "" # TCP mode
|
||||
|
||||
- name: Display PostgreSQL infrastructure status
|
||||
debug:
|
||||
msg: |
|
||||
✅ PostgreSQL infrastructure ready!
|
||||
|
||||
📡 Service: {{ postgresql_listen_addresses }}:{{ postgresql_port }}
|
||||
📡 Service: {% if postgresql_listen_addresses == "" %}Unix socket only at {{ postgresql_unix_socket_directories }}{% else %}{{ postgresql_listen_addresses }}:{{ postgresql_port }}{% endif %}
|
||||
🔒 Auth: {{ postgresql_auth_method }}
|
||||
📊 Checksums: {{ 'Enabled' if postgresql_data_checksums else 'Disabled' }}
|
||||
|
||||
|
||||
@@ -6,6 +6,10 @@
|
||||
listen_addresses = '{{ postgresql_listen_addresses }}'
|
||||
port = {{ postgresql_port }}
|
||||
|
||||
# Unix socket configuration
|
||||
unix_socket_directories = '{{ postgresql_unix_socket_directories | default("/run/postgresql") }}'
|
||||
unix_socket_permissions = {{ postgresql_unix_socket_permissions | default("0777") }}
|
||||
|
||||
# Basic Performance (only override if needed)
|
||||
max_connections = {{ postgresql_max_connections }}
|
||||
shared_buffers = {{ postgresql_shared_buffers }}
|
||||
|
||||
@@ -13,10 +13,14 @@
|
||||
valkey_service_enabled: true
|
||||
valkey_service_state: "started"
|
||||
|
||||
# Network Security (localhost only - matches PostgreSQL pattern)
|
||||
valkey_bind: "127.0.0.1"
|
||||
valkey_port: 6379
|
||||
valkey_protected_mode: true
|
||||
# Network Security (Unix socket with localhost TCP for compatibility)
|
||||
valkey_bind: "127.0.0.1" # Listen on localhost for apps that don't support Unix sockets
|
||||
valkey_port: 6379 # Keep TCP port for compatibility
|
||||
valkey_protected_mode: true # Enable protection for TCP
|
||||
|
||||
# Unix socket configuration (also enabled for better performance)
|
||||
valkey_unixsocket: "/run/valkey/valkey.sock"
|
||||
valkey_unixsocketperm: 777 # Allows container access
|
||||
|
||||
# Authentication
|
||||
valkey_password: "{{ vault_valkey_password }}"
|
||||
|
||||
@@ -15,6 +15,15 @@
|
||||
state: directory
|
||||
mode: '0755'
|
||||
|
||||
- name: Create Valkey socket directory
|
||||
file:
|
||||
path: /run/valkey
|
||||
state: directory
|
||||
owner: valkey
|
||||
group: valkey
|
||||
mode: '0755'
|
||||
when: valkey_unixsocket is defined
|
||||
|
||||
- name: Check if Valkey data directory exists
|
||||
stat:
|
||||
path: "/var/lib/valkey"
|
||||
@@ -55,19 +64,31 @@
|
||||
state: "{{ valkey_service_state }}"
|
||||
daemon_reload: yes
|
||||
|
||||
- name: Wait for Valkey to be ready
|
||||
- name: Wait for Valkey to be ready (TCP)
|
||||
wait_for:
|
||||
port: "{{ valkey_port }}"
|
||||
host: "{{ valkey_bind }}"
|
||||
host: "{{ valkey_bind | default('127.0.0.1') }}"
|
||||
timeout: 30
|
||||
when: valkey_service_state == "started"
|
||||
when:
|
||||
- valkey_service_state == "started"
|
||||
- valkey_port != 0
|
||||
|
||||
- name: Test Valkey connectivity
|
||||
command: valkey-cli -h {{ valkey_bind }} -p {{ valkey_port }} -a "{{ valkey_password }}" ping
|
||||
- name: Wait for Valkey Unix socket to be ready
|
||||
wait_for:
|
||||
path: "{{ valkey_unixsocket }}"
|
||||
timeout: 30
|
||||
when:
|
||||
- valkey_service_state == "started"
|
||||
- valkey_unixsocket is defined
|
||||
|
||||
- name: Test Valkey connectivity (Unix socket)
|
||||
command: valkey-cli -s {{ valkey_unixsocket }} -a "{{ valkey_password }}" ping
|
||||
register: valkey_ping_result
|
||||
changed_when: false
|
||||
failed_when: valkey_ping_result.stdout != "PONG"
|
||||
when: valkey_service_state == "started"
|
||||
when:
|
||||
- valkey_service_state == "started"
|
||||
- valkey_unixsocket is defined
|
||||
|
||||
- name: Display Valkey infrastructure status
|
||||
debug:
|
||||
|
||||
@@ -8,12 +8,22 @@
|
||||
# Network Configuration
|
||||
# =================================================================
|
||||
|
||||
# Bind to localhost only for security (like PostgreSQL)
|
||||
{% if valkey_bind %}
|
||||
# Bind to specified interfaces
|
||||
bind {{ valkey_bind }}
|
||||
{% else %}
|
||||
# No TCP binding - Unix socket only
|
||||
{% endif %}
|
||||
|
||||
# Valkey port
|
||||
# Valkey port (0 = disable TCP)
|
||||
port {{ valkey_port }}
|
||||
|
||||
# Unix socket configuration
|
||||
{% if valkey_unixsocket is defined %}
|
||||
unixsocket {{ valkey_unixsocket }}
|
||||
unixsocketperm {{ valkey_unixsocketperm }}
|
||||
{% endif %}
|
||||
|
||||
# Protected mode - requires authentication
|
||||
protected-mode {{ 'yes' if valkey_protected_mode else 'no' }}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user