parent
5abd511368
commit
1f988969a5
@ -0,0 +1,21 @@
|
||||
# Tips for deploying Matrix on a Budget
|
||||
|
||||
## Dynamic DNS
|
||||
|
||||
Most cloud providers / ISPs will charge you extra for a static IP address. If you're
|
||||
not hosting a highly reliable homeserver you can workaround this via dynamic DNS. To
|
||||
set this up, you'll need to get the username/password from your DNS provider. For
|
||||
google domains, this process is described [here](https://support.google.com/domains/answer/6147083).
|
||||
After you've gotten the proper credentials you can add the following config to your `host-vars`:
|
||||
|
||||
```
|
||||
matrix_dynamic_dns_username: XXXXXXXXXXXXXXXX
|
||||
matrix_dynamic_dns_password: XXXXXXXXXXXXXXXX
|
||||
matrix_dynamic_dns_provider: 'domains.google.com'
|
||||
```
|
||||
|
||||
## Additional Reading
|
||||
|
||||
Additional resources:
|
||||
|
||||
- https://matrix.org/docs/guides/free-small-matrix-server
|
@ -0,0 +1,14 @@
|
||||
# Whether dynamic dns is enabled
|
||||
matrix_dynamic_dns_enabled: true
|
||||
|
||||
# Allowed values: 'daemon', 'dhcp'
|
||||
matrix_dynamic_dns_mode: 'dhcp'
|
||||
|
||||
# The DNS provider domain
|
||||
matrix_dynamic_dns_provider: 'domains.google.com'
|
||||
|
||||
# The dynamic dns protocol
|
||||
matrix_dynamic_dns_protocol: 'dyndns2'
|
||||
|
||||
# The dynamic dns daemon interval
|
||||
matrix_dynamic_dns_daemon_interval: '300'
|
@ -0,0 +1,4 @@
|
||||
- set_fact:
|
||||
matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['ddclient'] }}"
|
||||
when: "matrix_dynamic_dns_enabled|bool"
|
||||
|
@ -0,0 +1,24 @@
|
||||
---
|
||||
|
||||
- name: Ensure ddclient domain config exists
|
||||
template:
|
||||
src: "{{ role_path }}/templates/ddclient.conf.j2"
|
||||
dest: "/etc/ddclient.conf"
|
||||
mode: 0600
|
||||
register: matrix_dynamic_dns_ddclient_domain_config
|
||||
|
||||
- name: Ensure ddclient client config directory exists
|
||||
file:
|
||||
path: "/etc/default"
|
||||
state: directory
|
||||
mode: 0700
|
||||
owner: "{{ user_username }}"
|
||||
group: "{{ user_groupname }}"
|
||||
|
||||
- name: Ensure ddclient client config exists
|
||||
template:
|
||||
src: "{{ role_path }}/templates/ddclient.j2"
|
||||
dest: "/etc/default/ddclient"
|
||||
mode: 0600
|
||||
register: matrix_dynamic_dns_ddclient_client_config
|
||||
|
@ -0,0 +1,28 @@
|
||||
- import_tasks: "{{ role_path }}/tasks/init.yml"
|
||||
tags:
|
||||
- always
|
||||
|
||||
- import_tasks: "{{ role_path }}/tasks/validate_config.yml"
|
||||
when: "run_setup|bool and matrix_dynamic_dns_enabled|bool"
|
||||
tags:
|
||||
- setup-all
|
||||
- setup-dynamic-dns
|
||||
|
||||
- import_tasks: "{{ role_path }}/tasks/install.yml"
|
||||
when: "run_setup|bool and matrix_dynamic_dns_enabled|bool"
|
||||
tags:
|
||||
- setup-all
|
||||
- setup-dynamic-dns
|
||||
|
||||
- import_tasks: "{{ role_path }}/tasks/platform/main.yml"
|
||||
when: "run_setup|bool"
|
||||
tags:
|
||||
- setup-all
|
||||
- setup-dynamic-dns
|
||||
|
||||
- import_tasks: "{{ role_path }}/tasks/uninstall.yml"
|
||||
when: "run_setup|bool and not matrix_dynamic_dns_enabled|bool"
|
||||
tags:
|
||||
- setup-all
|
||||
- setup-dynamic-dns
|
||||
|
@ -0,0 +1,16 @@
|
||||
---
|
||||
|
||||
- name: Ensure ddclient is installed
|
||||
pacman:
|
||||
name: ddclient
|
||||
state: latest
|
||||
when: "run_setup|bool and matrix_dynamic_dns_enabled|bool"
|
||||
|
||||
- name: Ensure ddclient is uninstalled
|
||||
pacman:
|
||||
name: ddclient
|
||||
state: absent
|
||||
update_cache: true
|
||||
become: true
|
||||
when: "run_setup|bool and not matrix_dynamic_dns_enabled|bool"
|
||||
|
@ -0,0 +1,23 @@
|
||||
---
|
||||
|
||||
- name: Ensure yum packages are installed
|
||||
yum:
|
||||
name: epel-release
|
||||
state: latest
|
||||
update_cache: yes
|
||||
when: "run_setup|bool and matrix_dynamic_dns_enabled|bool"
|
||||
|
||||
- name: Ensure ddclient is installed
|
||||
yum:
|
||||
name: ddclient
|
||||
state: latest
|
||||
when: "run_setup|bool and matrix_dynamic_dns_enabled|bool"
|
||||
|
||||
- name: Ensure ddclient is uninstalled
|
||||
yum:
|
||||
name:
|
||||
- ddclient
|
||||
- epel-release
|
||||
state: absent
|
||||
when: "run_setup|bool and not matrix_dynamic_dns_enabled|bool"
|
||||
|
@ -0,0 +1,18 @@
|
||||
---
|
||||
|
||||
- name: Ensure ddclient is installed
|
||||
apt:
|
||||
name: ddclient
|
||||
state: present
|
||||
update_cache: true
|
||||
become: true
|
||||
when: "run_setup|bool and matrix_dynamic_dns_enabled|bool"
|
||||
|
||||
- name: Ensure ddclient is uninstalled
|
||||
apt:
|
||||
name: ddclient
|
||||
state: absent
|
||||
update_cache: true
|
||||
become: true
|
||||
when: "run_setup|bool and not matrix_dynamic_dns_enabled|bool"
|
||||
|
@ -0,0 +1,11 @@
|
||||
---
|
||||
|
||||
- include_tasks: "{{ role_path }}/tasks/platform/centos.yml"
|
||||
when: ansible_distribution == 'CentOS'
|
||||
|
||||
# The instructions are the same for Debian, Ubuntu, and Raspbian
|
||||
- include_tasks: "{{ role_path }}/tasks/platform/debian.yml"
|
||||
when: ansible_distribution == 'Debian'
|
||||
|
||||
- include_tasks: "{{ role_path }}/tasks/platform/archlinux.yml"
|
||||
when: ansible_distribution == 'Archlinux'
|
@ -0,0 +1,31 @@
|
||||
---
|
||||
|
||||
- name: Check existence of ddclient.service
|
||||
stat:
|
||||
path: "{{ systemd_path }}/ddclient.service"
|
||||
register: matrix_dynamic_dns_ddclient_service_stat
|
||||
|
||||
- name: Ensure ddclient.service is stopped
|
||||
service:
|
||||
name: dynamic-dns
|
||||
state: stopped
|
||||
daemon_reload: yes
|
||||
when: "matrix_dynamic_dns_ddclient_service_stat.stat.exists"
|
||||
|
||||
- name: Ensure systemd reloaded after ddclient.service removal
|
||||
service:
|
||||
daemon_reload: yes
|
||||
when: "matrix_dynamic_dns_ddclient_service_stat.stat.exists"
|
||||
|
||||
- name: Ensure ddclient.service doesn't exist
|
||||
file:
|
||||
path: "{{ systemd_path }}/ddclient.service"
|
||||
state: absent
|
||||
when: "matrix_dynamic_dns_ddclient_service_stat.stat.exists"
|
||||
|
||||
- name: Ensure ddclient configuration files don't exist
|
||||
file:
|
||||
path:
|
||||
- "etc/ddclient.conf"
|
||||
- "etc/default/ddclient"
|
||||
state: absent
|
@ -0,0 +1,19 @@
|
||||
---
|
||||
|
||||
- name: Fail if required settings not defined
|
||||
fail:
|
||||
msg: >-
|
||||
You need to define a required configuration setting (`{{ item }}`).
|
||||
when: "vars[item] == ''"
|
||||
with_items:
|
||||
- "matrix_dynamic_dns_username"
|
||||
- "matrix_dynamic_dns_password"
|
||||
- "matrix_domain"
|
||||
- "matrix_dynamic_dns_provider"
|
||||
- "matrix_dynamic_dns_mode"
|
||||
|
||||
- name: Fail if dynamic dns mode is incorrect
|
||||
fail:
|
||||
msg: >-
|
||||
matrix_dynamic_dns_mode needs to be set to 'daemon' or 'startup'
|
||||
when: "matrix_dynamic_dns_enabled and matrix_dynamic_dns_mode != 'daemon' and matrix_dynamic_dns_mode != 'dhcp'"
|
@ -0,0 +1,7 @@
|
||||
protocol={{ matrix_dynamic_dns_protocol }}
|
||||
use=web
|
||||
ssl=yes
|
||||
server={{ matrix_dynamic_dns_provider }}
|
||||
login='{{ matrix_dynamic_dns_username }}'
|
||||
password='{{ matrix_dynamic_dns_password }}'
|
||||
{{ matrix_domain }}
|
@ -0,0 +1,4 @@
|
||||
run_dhclient="{{ (matrix_dynamic_dns_mode == 'dhcp') | lower }}"
|
||||
run_ipup="false"
|
||||
run_daemon="{{ (matrix_dynamic_dns_mode == 'daemon') | lower }}"
|
||||
daemon_interval="{{ matrix_dynamic_dns_daemon_interval }}"
|
Loading…
Reference in new issue