00_core.ymlยถ

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

- name: "๐Ÿงญ Remember the public view of this deploy for the CLI probe"
  ansible.builtin.set_fact:
    openpost_public_view:
      proxy_address: "{{ hostvars[STACK_HOST].ansible_facts.default_ipv4.address if IS_SWARM_MODE else '' }}"
      public_url: "{{ OPENPOST_URL }}"
      api_headers: "{{ OPENPOST_API_HEADERS }}"
      s3_public_url: "{{ lookup('objstore', application_id, 'public_url') | regex_replace('/?$', '/') if OPENPOST_OBJSTORE_ENABLED | bool else '' }}"
      smtp_enabled: "{{ OPENPOST_SMTP_ENABLED | bool }}"
      relay_targets: >-
        {%- set _targets = {} -%}
        {%- for _key, _role in OPENPOST_RELAY_SIBLINGS.items() if lookup('config', application_id, 'services.' ~ _key ~ '.enabled') | bool -%}
        {%- set _ = _targets.update({_key: lookup('domain', _role)}) -%}
        {%- endfor -%}
        {{ _targets }}
      routes: >-
        {%- set _routes = [] -%}
        {%- for _route in OPENPOST_CROSSPOSTER_ROUTES -%}
        {%- set _ = _routes.append({'name': _route.name, 'platform': _route.source.platform, 'base_url': _route.source.base_url, 'account': _route.source.account, 'mode': _route.mode, 'tags': _route.filters.tags, 'social_set': _route.targets.social_set | default('', true)}) -%}
        {%- endfor -%}
        {{ _routes }}

- name: "๐Ÿ”— Pin OpenPost apps on the sibling Mastodon and Pixelfed instances"
  include_tasks: 01_fediverse_apps.yml

- name: "๐Ÿงช Prepare the provider simulator"
  include_tasks:
    file: 02_simulator.yml
    apply:
      delegate_to: "{{ STACK_HOST }}"
      run_once: true
  when: OPENPOST_SIMULATOR_ENABLED | bool

- name: "๐Ÿงฉ load docker, db and proxy for {{ application_id }}"
  include_role:
    name: sys-stk-full
  vars:
    compose_handlers_flush: false
    webserver_extra_configuration: >-
      {{ lookup('template', 'nginx/echo_routes.conf.j2')
         ~ (lookup('file', lookup('path_absolute', 'roles/web-app-openpost/files/nginx/deny-password-registration.conf'))
            if OPENPOST_OIDC_ENABLED | bool else '') }}

- name: "๐Ÿ“„ Render the egress relay config (local + swarm peers)"
  ansible.builtin.include_tasks:
    file: "{{ lookup('path_absolute', 'roles/sys-svc-compose/tasks/utils/render_replicated_templates.yml') }}"
  vars:
    role_templates:
      - src: "relay.conf.j2"
        dest: "{{ OPENPOST_RELAY_CONF_HOST }}"
        mode: "0644"

- name: "๐Ÿ“ฎ Stage and render the crossposter"
  include_tasks: crossposter/render.yml
  when: OPENPOST_CROSSPOSTER_ENABLED | bool

- name: "๐ŸŽญ Stage and render the fake provider"
  include_tasks: provider/render.yml
  when: OPENPOST_PROVIDER_ENABLED | bool

- name: "๐Ÿšฟ flush handlers for '{{ application_id }}'"
  meta: flush_handlers

- name: "๐Ÿ”‘ Bootstrap the break-glass instance admin"
  include_tasks: 03_breakglass.yml
  when: IS_STACK_HOST | bool

- name: "๐Ÿ“ฎ Provision, apply and validate the crossposter"
  when: OPENPOST_CROSSPOSTER_ENABLED | bool
  block:
    - name: "๐Ÿ”‘ Provision the crossposter API token"
      include_tasks: crossposter/provision.yml
      when: IS_STACK_HOST | bool

    - name: "โœ… Apply and validate the crossposter"
      include_tasks: crossposter/apply.yml