parent
f308bcdcac
commit
ba0a4e864a
@ -1,35 +0,0 @@
|
||||
---
|
||||
# Project source code URL: https://github.com/devture/exim-relay
|
||||
|
||||
matrix_mailer_enabled: true
|
||||
|
||||
matrix_mailer_base_path: "{{ matrix_base_data_path }}/mailer"
|
||||
|
||||
matrix_mailer_container_image_self_build: false
|
||||
matrix_mailer_container_image_self_build_repository_url: "https://github.com/devture/exim-relay"
|
||||
matrix_mailer_container_image_self_build_src_files_path: "{{ matrix_mailer_base_path }}/docker-src"
|
||||
matrix_mailer_container_image_self_build_version: "{{ matrix_mailer_docker_image.split(':')[1] }}"
|
||||
|
||||
# renovate: datasource=docker depName=devture/exim-relay versioning=semver
|
||||
matrix_mailer_version: 4.97-r0-0
|
||||
matrix_mailer_docker_image: "{{ matrix_mailer_docker_image_name_prefix }}devture/exim-relay:{{ matrix_mailer_version }}"
|
||||
matrix_mailer_docker_image_name_prefix: "{{ 'localhost/' if matrix_mailer_container_image_self_build else matrix_container_global_registry_prefix }}"
|
||||
matrix_mailer_docker_image_force_pull: "{{ matrix_mailer_docker_image.endswith(':latest') }}"
|
||||
|
||||
# The user/group that the container runs with.
|
||||
# These match the `exim` user/group within the container image.
|
||||
matrix_mailer_container_user_uid: 100
|
||||
matrix_mailer_container_user_gid: 101
|
||||
|
||||
# A list of extra arguments to pass to the container
|
||||
matrix_mailer_container_extra_arguments: []
|
||||
|
||||
matrix_mailer_hostname: "{{ matrix_server_fqn_matrix }}"
|
||||
|
||||
matrix_mailer_sender_address: "matrix@{{ matrix_domain }}"
|
||||
matrix_mailer_relay_use: false
|
||||
matrix_mailer_relay_host_name: "mail.example.com"
|
||||
matrix_mailer_relay_host_port: 587
|
||||
matrix_mailer_relay_auth: false
|
||||
matrix_mailer_relay_auth_username: ""
|
||||
matrix_mailer_relay_auth_password: ""
|
@ -1,17 +0,0 @@
|
||||
---
|
||||
|
||||
- tags:
|
||||
- setup-all
|
||||
- setup-mailer
|
||||
- install-all
|
||||
- install-mailer
|
||||
block:
|
||||
- when: matrix_mailer_enabled | bool
|
||||
ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_install.yml"
|
||||
|
||||
- tags:
|
||||
- setup-all
|
||||
- setup-mailer
|
||||
block:
|
||||
- when: not matrix_mailer_enabled | bool
|
||||
ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_uninstall.yml"
|
@ -1,60 +0,0 @@
|
||||
---
|
||||
|
||||
- name: Ensure mailer base path exists
|
||||
ansible.builtin.file:
|
||||
path: "{{ item.path }}"
|
||||
state: directory
|
||||
mode: 0750
|
||||
owner: "{{ matrix_user_username }}"
|
||||
group: "{{ matrix_user_groupname }}"
|
||||
with_items:
|
||||
- {path: "{{ matrix_mailer_base_path }}", when: true}
|
||||
- {path: "{{ matrix_mailer_container_image_self_build_src_files_path }}", when: "{{ matrix_mailer_container_image_self_build }}"}
|
||||
when: item.when | bool
|
||||
|
||||
- name: Ensure mailer environment variables file created
|
||||
ansible.builtin.template:
|
||||
src: "{{ role_path }}/templates/env-mailer.j2"
|
||||
dest: "{{ matrix_mailer_base_path }}/env-mailer"
|
||||
mode: 0640
|
||||
|
||||
- name: Ensure exim-relay repository is present on self-build
|
||||
ansible.builtin.git:
|
||||
repo: "{{ matrix_mailer_container_image_self_build_repository_url }}"
|
||||
dest: "{{ matrix_mailer_container_image_self_build_src_files_path }}"
|
||||
version: "{{ matrix_mailer_container_image_self_build_version }}"
|
||||
force: "yes"
|
||||
become: true
|
||||
become_user: "{{ matrix_user_username }}"
|
||||
register: matrix_mailer_git_pull_results
|
||||
when: matrix_mailer_container_image_self_build | bool
|
||||
|
||||
- name: Ensure exim-relay Docker image is built
|
||||
community.docker.docker_image:
|
||||
name: "{{ matrix_mailer_docker_image }}"
|
||||
source: build
|
||||
force_source: "{{ matrix_mailer_git_pull_results.changed if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
|
||||
force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_mailer_git_pull_results.changed }}"
|
||||
build:
|
||||
dockerfile: Dockerfile
|
||||
path: "{{ matrix_mailer_container_image_self_build_src_files_path }}"
|
||||
pull: true
|
||||
when: matrix_mailer_container_image_self_build | bool
|
||||
|
||||
- name: Ensure exim-relay image is pulled
|
||||
community.docker.docker_image:
|
||||
name: "{{ matrix_mailer_docker_image }}"
|
||||
source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}"
|
||||
force_source: "{{ matrix_mailer_docker_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
|
||||
force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_mailer_docker_image_force_pull }}"
|
||||
when: "not matrix_mailer_container_image_self_build | bool"
|
||||
register: result
|
||||
retries: "{{ devture_playbook_help_container_retries_count }}"
|
||||
delay: "{{ devture_playbook_help_container_retries_delay }}"
|
||||
until: result is not failed
|
||||
|
||||
- name: Ensure matrix-mailer.service installed
|
||||
ansible.builtin.template:
|
||||
src: "{{ role_path }}/templates/systemd/matrix-mailer.service.j2"
|
||||
dest: "{{ devture_systemd_docker_base_systemd_path }}/matrix-mailer.service"
|
||||
mode: 0644
|
@ -1,25 +0,0 @@
|
||||
---
|
||||
|
||||
- name: Check existence of matrix-mailer service
|
||||
ansible.builtin.stat:
|
||||
path: "{{ devture_systemd_docker_base_systemd_path }}/matrix-mailer.service"
|
||||
register: matrix_mailer_service_stat
|
||||
|
||||
- when: matrix_mailer_service_stat.stat.exists | bool
|
||||
block:
|
||||
- name: Ensure matrix-mailer is stopped
|
||||
ansible.builtin.service:
|
||||
name: matrix-mailer
|
||||
state: stopped
|
||||
enabled: false
|
||||
daemon_reload: true
|
||||
|
||||
- name: Ensure matrix-mailer.service doesn't exist
|
||||
ansible.builtin.file:
|
||||
path: "{{ devture_systemd_docker_base_systemd_path }}/matrix-mailer.service"
|
||||
state: absent
|
||||
|
||||
- name: Ensure Matrix mailer path doesn't exist
|
||||
ansible.builtin.file:
|
||||
path: "{{ matrix_mailer_base_path }}"
|
||||
state: absent
|
@ -1,9 +0,0 @@
|
||||
#jinja2: lstrip_blocks: "True"
|
||||
{% if matrix_mailer_relay_use %}
|
||||
SMARTHOST={{ matrix_mailer_relay_host_name }}::{{ matrix_mailer_relay_host_port }}
|
||||
{% endif %}
|
||||
{% if matrix_mailer_relay_auth %}
|
||||
SMTP_USERNAME={{ matrix_mailer_relay_auth_username }}
|
||||
SMTP_PASSWORD={{ matrix_mailer_relay_auth_password }}
|
||||
{% endif %}
|
||||
HOSTNAME={{ matrix_mailer_hostname }}
|
@ -1,37 +0,0 @@
|
||||
#jinja2: lstrip_blocks: "True"
|
||||
[Unit]
|
||||
Description=Matrix mailer
|
||||
After=docker.service
|
||||
Requires=docker.service
|
||||
DefaultDependencies=no
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
Environment="HOME={{ devture_systemd_docker_base_systemd_unit_home_path }}"
|
||||
ExecStartPre=-{{ devture_systemd_docker_base_host_command_sh }} -c '{{ devture_systemd_docker_base_host_command_docker }} stop --time={{ devture_systemd_docker_base_container_stop_grace_time_seconds }} matrix-mailer 2>/dev/null || true'
|
||||
ExecStartPre=-{{ devture_systemd_docker_base_host_command_sh }} -c '{{ devture_systemd_docker_base_host_command_docker }} rm matrix-mailer 2>/dev/null || true'
|
||||
|
||||
# --hostname gives us a friendlier hostname than the default.
|
||||
# The real hostname is passed via a `HOSTNAME` environment variable though.
|
||||
ExecStart={{ devture_systemd_docker_base_host_command_docker }} run --rm --name matrix-mailer \
|
||||
--log-driver=none \
|
||||
--user={{ matrix_mailer_container_user_uid }}:{{ matrix_mailer_container_user_gid }} \
|
||||
--cap-drop=ALL \
|
||||
--read-only \
|
||||
--tmpfs=/var/spool/exim:rw,noexec,nosuid,size=100m \
|
||||
--network={{ matrix_docker_network }} \
|
||||
--env-file={{ matrix_mailer_base_path }}/env-mailer \
|
||||
--hostname=matrix-mailer \
|
||||
{% for arg in matrix_mailer_container_extra_arguments %}
|
||||
{{ arg }} \
|
||||
{% endfor %}
|
||||
{{ matrix_mailer_docker_image }}
|
||||
|
||||
ExecStop=-{{ devture_systemd_docker_base_host_command_sh }} -c '{{ devture_systemd_docker_base_host_command_docker }} stop --time={{ devture_systemd_docker_base_container_stop_grace_time_seconds }} matrix-mailer 2>/dev/null || true'
|
||||
ExecStop=-{{ devture_systemd_docker_base_host_command_sh }} -c '{{ devture_systemd_docker_base_host_command_docker }} rm matrix-mailer 2>/dev/null || true'
|
||||
Restart=always
|
||||
RestartSec=30
|
||||
SyslogIdentifier=matrix-mailer
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
@ -0,0 +1,39 @@
|
||||
---
|
||||
|
||||
# This migrates the mailer from the old path (`/matrix/mailer`) to the new path (`/matrix/exim-relay`, controlled by `exim_relay_base_path`),
|
||||
# and from the old hardcoded systemd service name (`matrix-mailer.service`) to the new one (`matrix-exim-relay.service`, controlled by `exim_relay_identifier`).
|
||||
#
|
||||
# Here, we merely disable (and stop) the old systemd service and relocate the base directory path (`/matrix/mailer`).
|
||||
# The exim-relay role itself (running later) will then ensure this data is up-to-date and will set up the new systemd service.
|
||||
|
||||
# It only makes sense to migrate if the identifier or path are different than the default (what we were using before).
|
||||
- name: Check existence of matrix-mailer.service systemd service
|
||||
ansible.builtin.stat:
|
||||
path: "{{ devture_systemd_docker_base_systemd_path }}/matrix-mailer.service"
|
||||
register: matrix_mailer_service_stat
|
||||
|
||||
- when: matrix_mailer_service_stat.stat.exists | bool
|
||||
block:
|
||||
- name: Ensure matrix-mailer.service systemd service is stopped
|
||||
ansible.builtin.systemd:
|
||||
name: matrix-mailer
|
||||
state: stopped
|
||||
enabled: false
|
||||
daemon_reload: true
|
||||
|
||||
- name: Ensure matrix-mailer directory relocated
|
||||
ansible.builtin.command:
|
||||
cmd: "mv {{ matrix_base_data_path }}/mailer {{ exim_relay_base_path }}"
|
||||
creates: "{{ exim_relay_base_path }}"
|
||||
removes: "{{ matrix_base_data_path }}"
|
||||
|
||||
# Remove legacy env-mailer file (named `env` in the new role)
|
||||
- name: Ensure old exim-relay environment variables file is deleted
|
||||
ansible.builtin.file:
|
||||
path: "{{ exim_relay_base_path }}/env-mailer"
|
||||
state: absent
|
||||
|
||||
- name: Ensure matrix-mailer.service systemd service doesn't exist
|
||||
ansible.builtin.file:
|
||||
path: "{{ devture_systemd_docker_base_systemd_path }}/matrix-mailer.service"
|
||||
state: absent
|
Loading…
Reference in new issue