mirror of
https://github.com/spantaleev/matrix-docker-ansible-deploy.git
synced 2024-11-06 02:37:31 +01:00
Added role for dynamic dns
This commit is contained in:
parent
5abd511368
commit
1f988969a5
21
docs/configuring-playbook-budget-builds.md
Normal file
21
docs/configuring-playbook-budget-builds.md
Normal file
@ -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
|
@ -33,6 +33,7 @@ When you're done with all the configuration you'd like to do, continue with [Ins
|
||||
|
||||
- [Setting up the Jitsi video-conferencing platform](configuring-playbook-jitsi.md) (optional)
|
||||
|
||||
- [Setting up budget builds or resource-constrained builds](configuring-playbook-budget-builds.md) (optional)
|
||||
|
||||
### Core service adjustments
|
||||
|
||||
|
14
roles/matrix-dynamic-dns/defaults/main.yml
Normal file
14
roles/matrix-dynamic-dns/defaults/main.yml
Normal file
@ -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'
|
4
roles/matrix-dynamic-dns/tasks/init.yml
Normal file
4
roles/matrix-dynamic-dns/tasks/init.yml
Normal file
@ -0,0 +1,4 @@
|
||||
- set_fact:
|
||||
matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['ddclient'] }}"
|
||||
when: "matrix_dynamic_dns_enabled|bool"
|
||||
|
24
roles/matrix-dynamic-dns/tasks/install.yml
Normal file
24
roles/matrix-dynamic-dns/tasks/install.yml
Normal file
@ -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
|
||||
|
28
roles/matrix-dynamic-dns/tasks/main.yml
Normal file
28
roles/matrix-dynamic-dns/tasks/main.yml
Normal file
@ -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
|
||||
|
16
roles/matrix-dynamic-dns/tasks/platform/archlinux.yml
Normal file
16
roles/matrix-dynamic-dns/tasks/platform/archlinux.yml
Normal file
@ -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"
|
||||
|
23
roles/matrix-dynamic-dns/tasks/platform/centos.yml
Normal file
23
roles/matrix-dynamic-dns/tasks/platform/centos.yml
Normal file
@ -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"
|
||||
|
18
roles/matrix-dynamic-dns/tasks/platform/debian.yml
Normal file
18
roles/matrix-dynamic-dns/tasks/platform/debian.yml
Normal file
@ -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"
|
||||
|
11
roles/matrix-dynamic-dns/tasks/platform/main.yml
Normal file
11
roles/matrix-dynamic-dns/tasks/platform/main.yml
Normal file
@ -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'
|
31
roles/matrix-dynamic-dns/tasks/uninstall.yml
Normal file
31
roles/matrix-dynamic-dns/tasks/uninstall.yml
Normal file
@ -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
|
19
roles/matrix-dynamic-dns/tasks/validate_config.yml
Normal file
19
roles/matrix-dynamic-dns/tasks/validate_config.yml
Normal file
@ -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'"
|
7
roles/matrix-dynamic-dns/templates/ddclient.conf.j2
Normal file
7
roles/matrix-dynamic-dns/templates/ddclient.conf.j2
Normal file
@ -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 }}
|
4
roles/matrix-dynamic-dns/templates/ddclient.j2
Normal file
4
roles/matrix-dynamic-dns/templates/ddclient.j2
Normal file
@ -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
Block a user