Support both binary & source install, improved README, fixed systemd service etc.
This commit is contained in:
parent
70ecff8caf
commit
318029b9a9
7 changed files with 93 additions and 14 deletions
26
README.md
26
README.md
|
@ -1,2 +1,26 @@
|
||||||
# matrixmailer
|
# Ansible role for matrixmailer
|
||||||
|
This role will install [matrixmailer](https://gitea.a-0.me/philip/matrixmailer) - either with pre-built binaries, or from source code directly on your system. It also sets up a systemd service and enables it.
|
||||||
|
|
||||||
|
# Supported operating systems
|
||||||
|
This playbook currently only supports debian systems. To suggest other platforms or contribute, feel free to join [#matrixmailer:a-0.me](matrix:r/matrixmailer:a-0.me).
|
||||||
|
|
||||||
|
Despite higher system performance requirements, I recommend self-building the binary as the cross compiling is still in an experimental stage.
|
||||||
|
|
||||||
|
# Configuration
|
||||||
|
See example playbooks for configuration samples.
|
||||||
|
|
||||||
|
Required variables:
|
||||||
|
- `matrixmailer_version`: Pinned version of matrixmailer to install, e.g. "0.1.0"
|
||||||
|
- `matrixmailer_build`: Either "from_source" if you want to build it yourself, or the build target for prebuilt binaries, like "x86_64-unknown-linux-musl"
|
||||||
|
- `matrixmailer_config`: Yaml content of the configuration file. You may want to consider importing it from a file rather than putting the file content directly into the playbook.
|
||||||
|
|
||||||
|
Optional variables:
|
||||||
|
- `matrixmailer_git_repo`: Only used when self-building the binary. Allows you to specify any URL a matrixmailer git repository can be pulled from.
|
||||||
|
|
||||||
|
# System requirements
|
||||||
|
matrixmailer itself is very lightweight. However, self-building matrixmailer is only recommended on systems with
|
||||||
|
- at least one "powerful" or two CPU cores, and
|
||||||
|
- at least 2GB memory.
|
||||||
|
|
||||||
|
# Disclaimer
|
||||||
|
Please be aware that this ansible role, as well as matrixmailer itself, are under active development. Be careful using it on production systems.
|
|
@ -1,2 +1,5 @@
|
||||||
---
|
---
|
||||||
matrixmailer_os_supported: False
|
matrixmailer_os_supported: False
|
||||||
|
|
||||||
|
matrixmailer_git_repo: https://gitea.a-0.me/philip/matrixmailer.git
|
||||||
|
matrixmailer_git_branch: "release-{{ matrixmailer_version }}"
|
9
example_playbook_fromsource.yml
Normal file
9
example_playbook_fromsource.yml
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
- hosts: host.example.com
|
||||||
|
roles:
|
||||||
|
- matrixmailer
|
||||||
|
vars:
|
||||||
|
- matrixmailer_version: "0.1.0"
|
||||||
|
- matrixmailer_build: "from_source"
|
||||||
|
- matrixmailer_config: "{{ lookup("file", "path/to/config/file/template.yaml") }}"
|
||||||
|
# The following option can be left out to use the default git repository
|
||||||
|
- matrixmailer_git_repo: "https://git.myorg.com/user/matrixmailer.git"
|
7
example_playbook_prebuilt.yml
Normal file
7
example_playbook_prebuilt.yml
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
- hosts: host.example.com
|
||||||
|
roles:
|
||||||
|
- matrixmailer
|
||||||
|
vars:
|
||||||
|
- matrixmailer_version: "0.1.0"
|
||||||
|
- matrixmailer_build: "x86_64-unknown-linux-musl"
|
||||||
|
- matrixmailer_config: "{{ lookup("file", "path/to/config/file/template.yaml") }}"
|
|
@ -20,10 +20,10 @@
|
||||||
vars:
|
vars:
|
||||||
__os_supported: "{{ lookup('vars', '{}_os_supported'.format(role_name)) | bool }}"
|
__os_supported: "{{ lookup('vars', '{}_os_supported'.format(role_name)) | bool }}"
|
||||||
|
|
||||||
- name: Assert matrixmailer version and system_spec are defined
|
- name: Assert matrixmailer version and build are defined
|
||||||
assert:
|
assert:
|
||||||
that: matrixmailer_version is defined and matrixmailer_system_spec is defined and matrixmailer_config is defined
|
that: matrixmailer_version is defined and matrixmailer_build 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."
|
fail_msg: "The ansible variables 'matrixmailer_version', 'matrixmailer_build' and 'matrixmailer_config' need to be set to run this role."
|
||||||
|
|
||||||
- name: Create matrixmailer group
|
- name: Create matrixmailer group
|
||||||
group:
|
group:
|
||||||
|
@ -40,14 +40,49 @@
|
||||||
password_lock: yes
|
password_lock: yes
|
||||||
state: present
|
state: present
|
||||||
|
|
||||||
- name: Download matrixmailer
|
- name: Install matrixmailer from pre-built binary
|
||||||
|
block:
|
||||||
|
- name: Download matrixmailer
|
||||||
become: yes
|
become: yes
|
||||||
get_url:
|
get_url:
|
||||||
url: "https://gitea.a-0.me/philip/matrixmailer/releases/download/{{ matrixmailer_version }}/{{ matrixmailer_system_spec }}"
|
url: "https://gitea.a-0.me/philip/matrixmailer/releases/download/{{ matrixmailer_version }}/{{ matrixmailer_build }}"
|
||||||
dest: "{{ matrixmailer_binary_location }}"
|
dest: "{{ matrixmailer_binary_location }}"
|
||||||
owner: "{{ matrixmailer_system_user }}"
|
owner: "{{ matrixmailer_system_user }}"
|
||||||
group: "{{ matrixmailer_system_group }}"
|
group: "{{ matrixmailer_system_group }}"
|
||||||
mode: 0500
|
mode: 0500
|
||||||
|
when: matrixmailer_build != "from_source"
|
||||||
|
|
||||||
|
- name: Install matrixmailer custom-built from git repository
|
||||||
|
block:
|
||||||
|
- name: Clone repository
|
||||||
|
git:
|
||||||
|
repo: "{{ matrixmailer_git_repo }}"
|
||||||
|
depth: 1
|
||||||
|
dest: "{{ matrixmailer_build_tmp }}"
|
||||||
|
version: "{{ matrixmailer_git_branch }}"
|
||||||
|
- name: Install required packages
|
||||||
|
apt:
|
||||||
|
pkg:
|
||||||
|
- libssl-dev
|
||||||
|
- pkg-config
|
||||||
|
- curl
|
||||||
|
state: present
|
||||||
|
- name: Install Rust
|
||||||
|
command:
|
||||||
|
cmd: "curl https://sh.rustup.rs -sSf | sh"
|
||||||
|
- name: Install matrixmailer
|
||||||
|
command:
|
||||||
|
cmd: cargo build --release
|
||||||
|
chdir: "{{ matrixmailer_build_tmp }}"
|
||||||
|
- name: Copy built binary to final location
|
||||||
|
copy:
|
||||||
|
remote_src: yes
|
||||||
|
src: "{{ matrixmailer_build_tmp }}"/release/matrixmailer
|
||||||
|
dest: "{{ matrixmailer_binary_location }}"
|
||||||
|
owner: "{{ matrixmailer_system_user }}"
|
||||||
|
group: "{{ matrixmailer_system_group }}"
|
||||||
|
mode: 0500
|
||||||
|
when: matrixmailer_build == "from_source"
|
||||||
|
|
||||||
- name: Create config file directory
|
- name: Create config file directory
|
||||||
file:
|
file:
|
||||||
|
|
|
@ -5,7 +5,7 @@ After=network.target
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=simple
|
Type=simple
|
||||||
ExecStart={{ matirxmailer_binary_location }} {{ matrixmailer_config_dir }}/config.yaml
|
ExecStart={{ matrixmailer_binary_location }} {{ matrixmailer_config_dir }}/config.yaml
|
||||||
Restart=always
|
Restart=always
|
||||||
RestartSec=1s
|
RestartSec=1s
|
||||||
User={{ matrixmailer_system_user }}
|
User={{ matrixmailer_system_user }}
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
---
|
---
|
||||||
matrixmailer_os_supported: True
|
matrixmailer_os_supported: True
|
||||||
|
|
||||||
matirxmailer_binary_location: /usr/bin/matrixmailer
|
matrixmailer_build_tmp: /tmp/matrixmailer
|
||||||
|
matrixmailer_binary_location: /usr/bin/matrixmailer
|
||||||
matrixmailer_config_dir: /etc/matrixmailer
|
matrixmailer_config_dir: /etc/matrixmailer
|
||||||
matrixmailer_systemd_service_file: /etc/systemd/system/matrixmailer.service
|
matrixmailer_systemd_service_file: /etc/systemd/system/matrixmailer.service
|
||||||
matrixmailer_system_user: matrixmailer
|
matrixmailer_system_user: matrixmailer
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue