activate.ymlΒΆ

---
# include-gated: when: stalwart_cert_missing | bool
- name: "πŸ”§ Register the platform TLS certificate with Stalwart"
  include_tasks: "{{ role_path }}/tasks/jmap_call.yml"
  vars:
    stalwart_jmap_body: >-
      {{ {'using': ['urn:ietf:params:jmap:core', 'urn:stalwart:jmap'],
          'methodCalls': [['x:Certificate/set', {'create': {'c': {
            'certificate': {'@type': 'File', 'filePath': '/etc/stalwart/certs/cert.pem'},
            'privateKey': {'@type': 'File', 'filePath': '/etc/stalwart/certs/key.pem'}
          }}}, 'c0']]} | to_json }}

- name: "πŸ”„ Restart Stalwart to activate the registered certificate (compose)"
  ansible.builtin.command: "container restart {{ STALWART_CONTAINER }}"
  changed_when: true
  when: IS_COMPOSE_MODE

- name: "πŸ”„ Restart Stalwart to activate the registered certificate (swarm)"
  ansible.builtin.command: "container service update --force {{ lookup('container_service', application_id, 'stalwart') }}"
  changed_when: true
  timeout: "{{ lookup('timeout', 600) | int }}"
  when: IS_SWARM_MODE

- name: "⏳ Wait for Stalwart API after the certificate restart"
  include_tasks: "{{ role_path }}/tasks/01_wait_for_api.yml"