Initial commit
This commit is contained in:
parent
efe2374c19
commit
70ecff8caf
6 changed files with 104 additions and 0 deletions
2
defaults/main.yml
Normal file
2
defaults/main.yml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
---
|
||||||
|
matrixmailer_os_supported: False
|
1
handlers/main.yml
Normal file
1
handlers/main.yml
Normal file
|
@ -0,0 +1 @@
|
||||||
|
---
|
2
meta/main.yml
Normal file
2
meta/main.yml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
---
|
||||||
|
galaxy_info:
|
76
tasks/main.yml
Normal file
76
tasks/main.yml
Normal file
|
@ -0,0 +1,76 @@
|
||||||
|
---
|
||||||
|
- 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
|
15
templates/matrixmailer.service.j2
Normal file
15
templates/matrixmailer.service.j2
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
[Unit]
|
||||||
|
Description=matrixmailer - Send e-mail to [matrix]
|
||||||
|
After=syslog.target
|
||||||
|
After=network.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=simple
|
||||||
|
ExecStart={{ matirxmailer_binary_location }} {{ matrixmailer_config_dir }}/config.yaml
|
||||||
|
Restart=always
|
||||||
|
RestartSec=1s
|
||||||
|
User={{ matrixmailer_system_user }}
|
||||||
|
Group={{ matrixmailer_system_group }}
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
8
vars/debian.yml
Normal file
8
vars/debian.yml
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
---
|
||||||
|
matrixmailer_os_supported: True
|
||||||
|
|
||||||
|
matirxmailer_binary_location: /usr/bin/matrixmailer
|
||||||
|
matrixmailer_config_dir: /etc/matrixmailer
|
||||||
|
matrixmailer_systemd_service_file: /etc/systemd/system/matrixmailer.service
|
||||||
|
matrixmailer_system_user: matrixmailer
|
||||||
|
matrixmailer_system_group: "{{ matrixmailer_system_user }}"
|
Loading…
Add table
Add a link
Reference in a new issue