---
# The domain was asserted provisionable in 00_core.yml before any state change.
- name: "๐ List existing Stalwart domains"
include_tasks: jmap_call.yml
vars:
stalwart_jmap_body: >-
{{ {'using': ['urn:ietf:params:jmap:core', 'urn:stalwart:jmap'],
'methodCalls': [['x:Domain/get', {'ids': none}, 'c0']]} | to_json }}
- name: "๐ Resolve existing domain id (if any)"
ansible.builtin.set_fact:
stalwart_domain_id: >-
{{ (stalwart_jmap.methodResponses[0][1].list
| selectattr('name', 'equalto', STALWART_DOMAIN)
| map(attribute='id') | first) | default('') }}
- name: "๐ Create the Stalwart domain when it does not exist yet"
when: stalwart_domain_id | length == 0
block:
- name: "๐ Create Stalwart domain '{{ STALWART_DOMAIN }}'"
include_tasks: jmap_call.yml
vars:
stalwart_jmap_body: >-
{{ {'using': ['urn:ietf:params:jmap:core', 'urn:stalwart:jmap'],
'methodCalls': [['x:Domain/set',
{'create': {'d': {'name': STALWART_DOMAIN}}}, 'c0']]} | to_json }}
- name: "๐ Capture newly created domain id"
ansible.builtin.set_fact:
stalwart_domain_id: "{{ stalwart_jmap.methodResponses[0][1].created.d.id }}"
- name: "โ๏ธ Provision Stalwart accounts"
include_tasks: 04_manage_user.yml
when: STALWART_USERS | length > 0
- name: "๐ง Configure Stalwart mail-listener TLS (platform cert)"
include_tasks: 05_tls.yml
when: (lookup('tls', application_id, 'enabled') | bool) or (STALWART_ACTIVE_PROVIDER | bool)
- name: "๐ Wire Keycloak as the OIDC authentication directory (SSO)"
include_tasks: 06_oidc.yml
when: STALWART_SSO_ENABLED | bool
- name: "๐ง Register the ClamAV antivirus milter"
include_tasks: 07_antivirus.yml
when: STALWART_ANTIVIRUS_ENABLED | bool
- name: "๐ Read Stalwart-managed DKIM public key"
include_tasks: 08_read_dkim.yml
- name: "๐ง Publish Stalwart DNS records"
include_tasks: 09_dns-records.yml
when: stalwart_dkim_selector is defined
- name: "๐ Verify the production mail server's public configuration"
include_tasks: 13_production_facts.yml
when: STALWART_PRODUCTION_HOST | length > 0
- name: "๐ง
Route .onion recipients through the Tor SMTP gateway"
include_tasks: 14_onion_route.yml
when: STALWART_ONION_ACTIVE | bool
- name: "๐ฎ Provision the declared mail aliases and catch-alls"
include_tasks: 15_aliases.yml
- name: "๐ Deliver the mail of the alias domains to their target domains"
include_tasks: 17_alias_domains.yml
when: STALWART_ALIAS_DOMAINS | length > 0