GNAI-025: Fluxer-Chat-LXC CT 117 — komplett in Betrieb (fluxer.ghostnet.selfhost.eu) #21
@@ -109,32 +109,28 @@
|
||||
notify:
|
||||
- Restart the Fluxer stack
|
||||
|
||||
- name: Check whether the secrets file already exists
|
||||
ansible.builtin.stat:
|
||||
path: "{{ fluxer_stack_secrets_file }}"
|
||||
register: fluxer_stack_secrets_stat
|
||||
|
||||
- name: Generate the Fluxer secrets once on the guest (never in git)
|
||||
- name: Ensure all Fluxer secrets exist on the guest (idempotent append, never in git)
|
||||
ansible.builtin.shell: |
|
||||
set -Eeuo pipefail
|
||||
umask 077
|
||||
tmp="$(mktemp "{{ fluxer_stack_secrets_file }}.XXXXXX")"
|
||||
trap 'rm -f "$tmp"' EXIT
|
||||
f="{{ fluxer_stack_secrets_file }}"
|
||||
touch "$f"
|
||||
{% for name, nbytes in fluxer_stack_secret_specs.items() %}
|
||||
printf '%s=%s\n' '{{ name }}' "$(/usr/bin/openssl rand -hex {{ nbytes }})" >> "$tmp"
|
||||
grep -q "^{{ name }}=" "$f" || printf '%s=%s\n' '{{ name }}' "$(/usr/bin/openssl rand -hex {{ nbytes }})" >> "$f"
|
||||
{% endfor %}
|
||||
printf 'FLUXER_MEDIA_PROXY_UPLOAD_RELAY_SECRET_BASE64=%s\n' "$(/usr/bin/openssl rand -base64 36)" >> "$tmp"
|
||||
# VAPID web-push keypair (EC P-256, base64-DER wie von Fluxer erwartet)
|
||||
/usr/bin/openssl ecparam -name prime256v1 -genkey -noout -out "$tmp.vapid.pem"
|
||||
printf 'FLUXER_VAPID_PRIVATE_KEY=%s\n' "$(/usr/bin/openssl pkcs8 -topk8 -nocrypt -in "$tmp.vapid.pem" -outform DER | /usr/bin/base64 -w0)" >> "$tmp"
|
||||
printf 'FLUXER_VAPID_PUBLIC_KEY=%s\n' "$(/usr/bin/openssl ec -in "$tmp.vapid.pem" -pubout -outform DER | /usr/bin/tail -c 65 | /usr/bin/base64 -w0)" >> "$tmp"
|
||||
rm -f "$tmp.vapid.pem"
|
||||
mv "$tmp" "{{ fluxer_stack_secrets_file }}"
|
||||
trap - EXIT
|
||||
grep -q '^FLUXER_MEDIA_PROXY_UPLOAD_RELAY_SECRET_BASE64=' "$f" \
|
||||
|| printf 'FLUXER_MEDIA_PROXY_UPLOAD_RELAY_SECRET_BASE64=%s\n' "$(/usr/bin/openssl rand -base64 36)" >> "$f"
|
||||
if ! grep -q '^FLUXER_VAPID_PRIVATE_KEY=' "$f" || ! grep -q '^FLUXER_VAPID_PUBLIC_KEY=' "$f"; then
|
||||
# VAPID web-push keypair (EC P-256, base64-DER wie von Fluxer erwartet)
|
||||
/usr/bin/openssl ecparam -name prime256v1 -genkey -noout -out "$f.vapid.pem"
|
||||
printf 'FLUXER_VAPID_PRIVATE_KEY=%s\n' "$(/usr/bin/openssl pkcs8 -topk8 -nocrypt -in "$f.vapid.pem" -outform DER | /usr/bin/base64 -w0)" >> "$f"
|
||||
printf 'FLUXER_VAPID_PUBLIC_KEY=%s\n' "$(/usr/bin/openssl ec -in "$f.vapid.pem" -pubout -outform DER | /usr/bin/tail -c 65 | /usr/bin/base64 -w0)" >> "$f"
|
||||
rm -f "$f.vapid.pem"
|
||||
fi
|
||||
args:
|
||||
executable: /bin/bash
|
||||
changed_when: true
|
||||
when: not fluxer_stack_secrets_stat.stat.exists
|
||||
when: not ansible_check_mode
|
||||
|
||||
- name: Enforce root-only permissions on the secrets file
|
||||
ansible.builtin.file:
|
||||
|
||||
Reference in New Issue
Block a user