00_core.ymlΒΆ

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

- name: "🧩 Load docker, db and proxy for {{ application_id }}"
  include_role:
    name: sys-stk-full
  vars:
    compose_handlers_flush: false

- name: "πŸͺ Stage n8n SSO auto-provisioning hook on stack host and swarm peers"
  ansible.builtin.include_tasks:
    file: "{{ lookup('path_absolute', 'roles/sys-svc-compose/tasks/utils/render_replicated_templates.yml') }}"
  vars:
    role_templates:
      - src: "{{ lookup('path_absolute', 'roles/web-app-n8n/files/javascript/hooks.js') }}"
        dest: "{{ N8N_HOOKS_FILE_HOST }}"
        mode: "0644"
        notify: ["compose-up"]
  when: N8N_SSO_ENABLED | bool

- name: "🚿 Flush handlers so '{{ N8N_CONTAINER }}' restarts with the SSO hook mounted"
  meta: flush_handlers

- name: "⏳ Wait for n8n HTTP endpoint"
  wait_for:
    host: "{{ DOCKER_REACH_HOST }}"
    port: "{{ N8N_HTTP_PORT }}"
    delay: 5
    timeout: "{{ lookup('timeout', 300) | int }}"

- name: "πŸ”Ž Wait for n8n health check to pass"
  uri_retry:
    url: "{{ N8N_INTERNAL_API_URL }}/healthz/readiness"
    method: GET
    status_code: 200
    return_content: false
  register: n8n_health
  until: n8n_health.status == 200
  retries: 60
  delay: 5

- name: "πŸ‘€ Bootstrap n8n owner account"
  include_tasks:
    file: 01_bootstrap.yml
    apply:
      run_once: true

- name: "πŸ€– Bind the native AI surface to the platform gateway"
  include_tasks:
    file: utils/ai_gateway.yml
  when: N8N_LITELLM_ENABLED | bool

- name: "πŸ”Œ Provision the MCP surface"
  include_tasks:
    file: utils/mcp.yml
    apply:
      no_log: "{{ MASK_CREDENTIALS_IN_LOGS | bool }}"
  when: N8N_MCP_ENABLED | bool