00_core.ymlΒΆ

---
- include_tasks: utils/once/flag.yml

- name: "πŸ”Œ Stage the MCP adapter instance for {{ application_id }}"
  ansible.builtin.include_tasks: "{{ lookup('path_absolute', 'roles/svc-ai-mcp-adapter/tasks/instance.yml') }}"
  vars:
    mcp_adapter_instance_dir: "{{ JELLYFIN_MCP_INSTANCE_DIR }}"
    mcp_adapter_upstream_key: true
  when: JELLYFIN_MCP_ENABLED | bool
- name: "🧩 load docker, db and proxy for {{ application_id }}"
  include_role:
    name: sys-stk-full
  vars:
    application_id: "web-app-jellyfin"
    compose_handlers_flush: true

- name: "πŸ” Provision auth and apply the corporate design on the stack host"
  when: IS_STACK_HOST | bool
  block:
    - name: "πŸ” Provision Jellyfin auth (wizard, LDAP/OIDC plugins) for {{ application_id }}"
      vars:
        jellyfin_auth_env_base:
          JELLYFIN_API: "{{ JELLYFIN_API }}"
          JELLYFIN_ADMIN_USERNAME: "{{ JELLYFIN_ADMIN_USERNAME }}"
          JELLYFIN_ADMIN_PASSWORD: "{{ JELLYFIN_ADMIN_PASSWORD }}"
          JELLYFIN_SSO_ENABLED: "{{ JELLYFIN_SSO_ENABLED | string | lower }}"
          JELLYFIN_LDAP_ENABLED: "{{ JELLYFIN_LDAP_ENABLED | string | lower }}"
        jellyfin_auth_env_ldap:
          JELLYFIN_LDAP_PLUGIN_VERSION: "{{ JELLYFIN_LDAP_PLUGIN_VERSION }}"
          JELLYFIN_LDAP_PLUGIN_URL: "{{ JELLYFIN_LDAP_PLUGIN_URL }}"
          JELLYFIN_LDAP_PLUGIN_MD5: "{{ JELLYFIN_LDAP_PLUGIN_MD5 }}"
          JELLYFIN_LDAP_SERVER: "{{ JELLYFIN_LDAP_SERVER }}"
          JELLYFIN_LDAP_PORT: "{{ JELLYFIN_LDAP_PORT }}"
          JELLYFIN_LDAP_BIND_DN: "{{ JELLYFIN_LDAP_BIND_DN }}"
          JELLYFIN_LDAP_BIND_PASSWORD: "{{ JELLYFIN_LDAP_BIND_PASSWORD }}"
          JELLYFIN_LDAP_BASE_DN: "{{ JELLYFIN_LDAP_BASE_DN }}"
          JELLYFIN_LDAP_UID_ATTR: "{{ JELLYFIN_LDAP_UID_ATTR }}"
        jellyfin_auth_env_sso:
          JELLYFIN_SSO_PLUGIN_MANIFEST: "{{ JELLYFIN_SSO_PLUGIN_MANIFEST }}"
          JELLYFIN_OIDC_ISSUER: "{{ JELLYFIN_OIDC_ISSUER }}"
          JELLYFIN_OIDC_DISABLE_HTTPS: "{{ (JELLYFIN_OIDC_ISSUER | urlsplit('scheme') != 'https') | string | lower }}"
          JELLYFIN_OIDC_CLIENT_ID: "{{ JELLYFIN_OIDC_CLIENT_ID }}"
          JELLYFIN_OIDC_CLIENT_SECRET: "{{ JELLYFIN_OIDC_CLIENT_SECRET }}"
        jellyfin_auth_env: >-
          {{ jellyfin_auth_env_base
             | combine(jellyfin_auth_env_ldap if JELLYFIN_LDAP_ENABLED | bool else {})
             | combine(jellyfin_auth_env_sso if JELLYFIN_SSO_ENABLED | bool else {}) }}
      ansible.builtin.include_tasks: 00_core/auth.yml

    - name: "🎨 Apply the corporate design of {{ application_id }}"
      vars:
        jellyfin_design_authorization: 'MediaBrowser Token="{{ jellyfin_design_session.json.AccessToken }}"'
        jellyfin_design_title: "{{ lookup('design', application_id).title if JELLYFIN_DESIGN_ENABLED | bool else false }}"
        jellyfin_design_css_current: "{{ jellyfin_design_branding.json.get('CustomCss') or '' }}"
        jellyfin_design_css_foreign: "{{ jellyfin_design_css_current | regex_replace(JELLYFIN_DESIGN_CSS_PATTERN, '') | trim }}"
        jellyfin_design_urls: "{{ lookup('design', application_id).relative_urls }}"
        jellyfin_design_css_block: "{{ (JELLYFIN_DESIGN_CSS_OPEN ~ (lookup('template', 'branding.css.j2') | trim) ~ JELLYFIN_DESIGN_CSS_CLOSE) if JELLYFIN_DESIGN_ENABLED
          | bool else '' }}"
        jellyfin_design_css: "{{ [jellyfin_design_css_foreign, jellyfin_design_css_block] | select | join('\n') }}"
      ansible.builtin.include_tasks:
        file: utils/design.yml
        apply:
          delegate_to: "{{ JELLYFIN_HOST_NODE }}"
          no_log: "{{ MASK_CREDENTIALS_IN_LOGS | bool }}"

- name: "πŸ”Œ Serve MCP from {{ application_id }}"
  ansible.builtin.include_tasks: utils/mcp.yml
  when: JELLYFIN_MCP_ENABLED | bool