tasks/ldap.yml keeps cn=Funkwhale (password from Vault, in Funkwhale Users, Postfix Users and Dovecot Users). Mail goes out as funkwhale@eom.dev instead of listmonk's news account, and the account is a Dex superuser. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
134 lines
5.5 KiB
YAML
134 lines
5.5 KiB
YAML
# SPDX-License-Identifier: MIT-0
|
|
---
|
|
- name: Validate required secrets
|
|
ansible.builtin.assert:
|
|
that:
|
|
- funkwhale_smtp_password | length > 0
|
|
- not funkwhale_oidc_enabled | bool or funkwhale_oidc_client_secret | length > 0
|
|
fail_msg: Set funkwhale_smtp_password and funkwhale_oidc_client_secret (Vault).
|
|
quiet: true
|
|
|
|
- name: Keep the service's LDAP account
|
|
ansible.builtin.include_tasks: ldap.yml
|
|
when: funkwhale_ldap_manage | bool
|
|
|
|
- name: Read the existing credentials
|
|
kubernetes.core.k8s_info:
|
|
kubeconfig: "{{ funkwhale_kubeconfig | default(omit, true) }}"
|
|
context: "{{ funkwhale_kube_context | default(omit, true) }}"
|
|
kind: Secret
|
|
namespace: "{{ funkwhale_namespace }}"
|
|
name: "{{ funkwhale_name }}"
|
|
register: _funkwhale_secret
|
|
no_log: true
|
|
|
|
# Vault values win. Otherwise keep what the cluster already has, so the
|
|
# database password and Django key never change behind Funkwhale's back;
|
|
# on the first run, generate them.
|
|
- name: Use, reuse or generate the instance secrets
|
|
ansible.builtin.set_fact:
|
|
funkwhale_django_secret_key: "{{ funkwhale_django_secret_key or _existing.DJANGO_SECRET_KEY | default('') | b64decode or lookup('ansible.builtin.password', '/dev/null', chars=['ascii_letters', 'digits'], length=64) }}"
|
|
funkwhale_db_password: "{{ funkwhale_db_password or _existing.DATABASE_PASSWORD | default('') | b64decode or lookup('ansible.builtin.password', '/dev/null', chars=['ascii_letters', 'digits'], length=32) }}"
|
|
funkwhale_admin_password: "{{ funkwhale_admin_password or _existing.FUNKWHALE_CLI_USER_PASSWORD | default('') | b64decode or lookup('ansible.builtin.password', '/dev/null', chars=['ascii_letters', 'digits'], length=32) }}"
|
|
vars:
|
|
_existing: "{{ (_funkwhale_secret.resources | first).data if _funkwhale_secret.resources else {} }}"
|
|
no_log: true
|
|
|
|
- name: Check secret lengths
|
|
ansible.builtin.assert:
|
|
that:
|
|
- funkwhale_django_secret_key | length >= 50
|
|
- funkwhale_db_password | length >= 16
|
|
- funkwhale_admin_password | length >= 12
|
|
fail_msg: funkwhale_django_secret_key needs 50+ chars, funkwhale_db_password 16+, funkwhale_admin_password 12+.
|
|
quiet: true
|
|
no_log: true
|
|
|
|
- name: Create namespace
|
|
kubernetes.core.k8s:
|
|
kubeconfig: "{{ funkwhale_kubeconfig | default(omit, true) }}"
|
|
context: "{{ funkwhale_kube_context | default(omit, true) }}"
|
|
state: present
|
|
definition:
|
|
apiVersion: v1
|
|
kind: Namespace
|
|
metadata:
|
|
name: "{{ funkwhale_namespace }}"
|
|
when: funkwhale_create_namespace | bool
|
|
|
|
- name: Store credentials
|
|
kubernetes.core.k8s:
|
|
kubeconfig: "{{ funkwhale_kubeconfig | default(omit, true) }}"
|
|
context: "{{ funkwhale_kube_context | default(omit, true) }}"
|
|
state: present
|
|
apply: true
|
|
definition: "{{ lookup('ansible.builtin.template', 'secret.yml.j2') | from_yaml }}"
|
|
no_log: true
|
|
|
|
- name: Store configuration
|
|
kubernetes.core.k8s:
|
|
kubeconfig: "{{ funkwhale_kubeconfig | default(omit, true) }}"
|
|
context: "{{ funkwhale_kube_context | default(omit, true) }}"
|
|
state: present
|
|
apply: true
|
|
definition: "{{ lookup('ansible.builtin.template', 'config.yml.j2') | from_yaml }}"
|
|
|
|
- name: Store the theme
|
|
kubernetes.core.k8s:
|
|
kubeconfig: "{{ funkwhale_kubeconfig | default(omit, true) }}"
|
|
context: "{{ funkwhale_kube_context | default(omit, true) }}"
|
|
state: present
|
|
apply: true
|
|
definition: "{{ lookup('ansible.builtin.template', 'theme-configmap.yml.j2') | from_yaml }}"
|
|
|
|
- name: Deploy PostgreSQL
|
|
kubernetes.core.k8s:
|
|
kubeconfig: "{{ funkwhale_kubeconfig | default(omit, true) }}"
|
|
context: "{{ funkwhale_kube_context | default(omit, true) }}"
|
|
state: present
|
|
apply: true
|
|
definition: "{{ lookup('ansible.builtin.template', 'postgres.yml.j2') | from_yaml_all | list }}"
|
|
wait: true
|
|
wait_timeout: "{{ funkwhale_wait_timeout }}"
|
|
|
|
- name: Deploy Funkwhale
|
|
kubernetes.core.k8s:
|
|
kubeconfig: "{{ funkwhale_kubeconfig | default(omit, true) }}"
|
|
context: "{{ funkwhale_kube_context | default(omit, true) }}"
|
|
state: present
|
|
apply: true
|
|
definition: "{{ lookup('ansible.builtin.template', 'funkwhale.yml.j2') | from_yaml_all | list }}"
|
|
wait: true
|
|
wait_timeout: "{{ funkwhale_wait_timeout }}"
|
|
|
|
- name: Find the API pod
|
|
kubernetes.core.k8s_info:
|
|
kubeconfig: "{{ funkwhale_kubeconfig | default(omit, true) }}"
|
|
context: "{{ funkwhale_kube_context | default(omit, true) }}"
|
|
kind: Pod
|
|
namespace: "{{ funkwhale_namespace }}"
|
|
label_selectors:
|
|
- app.kubernetes.io/instance={{ funkwhale_name }}
|
|
- app.kubernetes.io/component=api
|
|
field_selectors:
|
|
- status.phase=Running
|
|
register: _funkwhale_api_pods
|
|
failed_when: _funkwhale_api_pods.resources | length == 0
|
|
|
|
# Preferences live in the database, not in the environment. Funkwhale
|
|
# caches them, so changes show up without a restart.
|
|
- name: Converge instance preferences (and the break-glass admin)
|
|
kubernetes.core.k8s_exec:
|
|
kubeconfig: "{{ funkwhale_kubeconfig | default(omit, true) }}"
|
|
context: "{{ funkwhale_kube_context | default(omit, true) }}"
|
|
namespace: "{{ funkwhale_namespace }}"
|
|
pod: "{{ (_funkwhale_api_pods.resources | sort(attribute='metadata.creationTimestamp') | last).metadata.name }}"
|
|
container: api
|
|
command: >-
|
|
sh -c 'echo {{ lookup('ansible.builtin.template', 'configure.py.j2') | b64encode }}
|
|
| base64 -d > /tmp/configure.py && funkwhale-manage shell -c "$(cat /tmp/configure.py)";
|
|
rc=$?; rm -f /tmp/configure.py; exit $rc'
|
|
register: funkwhale_configure
|
|
changed_when: (funkwhale_configure.stdout_lines | last | int) > 0
|
|
no_log: true
|