76 lines
2.4 KiB
YAML
76 lines
2.4 KiB
YAML
|
---
|
||
|
- name: Set OS dependent variables
|
||
|
ansible.builtin.include_vars: "{{ lookup('first_found', params) }}"
|
||
|
vars:
|
||
|
params:
|
||
|
files:
|
||
|
- "{{ ansible_distribution | lower }}_{{ ansible_distribution_version | lower }}.yml"
|
||
|
- "{{ ansible_distribution | lower }}_{{ ansible_distribution_major_version | lower }}.yml"
|
||
|
- "{{ ansible_distribution | lower }}.yml"
|
||
|
- "{{ ansible_os_family | lower }}.yml"
|
||
|
- "{{ ansible_system | lower }}.yml"
|
||
|
paths:
|
||
|
- '{{ role_path }}/vars'
|
||
|
ignore_errors: True
|
||
|
|
||
|
- name: OS is supported
|
||
|
ansible.builtin.assert:
|
||
|
that: __os_supported
|
||
|
quiet: True
|
||
|
vars:
|
||
|
__os_supported: "{{ lookup('vars', '{}_os_supported'.format(role_name)) | bool }}"
|
||
|
|
||
|
- name: Assert matrixmailer version and system_spec are defined
|
||
|
assert:
|
||
|
that: matrixmailer_version is defined and matrixmailer_system_spec is defined and matrixmailer_config is defined
|
||
|
fail_msg: "The ansible variables 'matrixmailer_version', 'matrixmailer_system_spec' and 'matrixmailer_config' need to be set to run this role."
|
||
|
|
||
|
- name: Create matrixmailer group
|
||
|
group:
|
||
|
name: "{{ matrixmailer_system_group }}"
|
||
|
state: present
|
||
|
|
||
|
- name: Create matrixmailer user
|
||
|
user:
|
||
|
name: "{{ matrixmailer_system_user }}"
|
||
|
group: "{{ matrixmailer_system_group }}"
|
||
|
comment: "Send e-mail to [matrix]"
|
||
|
system: yes
|
||
|
create_home: no
|
||
|
password_lock: yes
|
||
|
state: present
|
||
|
|
||
|
- name: Download matrixmailer
|
||
|
become: yes
|
||
|
get_url:
|
||
|
url: "https://gitea.a-0.me/philip/matrixmailer/releases/download/{{ matrixmailer_version }}/{{ matrixmailer_system_spec }}"
|
||
|
dest: "{{ matrixmailer_binary_location }}"
|
||
|
owner: "{{ matrixmailer_system_user }}"
|
||
|
group: "{{ matrixmailer_system_group }}"
|
||
|
mode: 0500
|
||
|
|
||
|
- name: Create config file directory
|
||
|
file:
|
||
|
name: "{{ matrixmailer_config_dir }}"
|
||
|
group: "{{ matrixmailer_system_group }}"
|
||
|
mode: 0770
|
||
|
state: directory
|
||
|
|
||
|
- name: Set config file
|
||
|
copy:
|
||
|
content: "{{ matrixmailer_config }}"
|
||
|
dest: "{{ matrixmailer_config_dir }}/config.yaml"
|
||
|
owner: "{{ matrixmailer_system_user }}"
|
||
|
group: "{{ matrixmailer_system_group }}"
|
||
|
mode: 0600
|
||
|
|
||
|
- name: Set systemd service
|
||
|
template:
|
||
|
src: matrixmailer.service.j2
|
||
|
dest: "{{ matrixmailer_systemd_service_file }}"
|
||
|
|
||
|
- name: Enable and (re)start systemd service
|
||
|
service:
|
||
|
name: matrixmailer
|
||
|
enabled: yes
|
||
|
state: restarted
|