parent
53bc7a77e1
commit
51cca4c312
@ -1,14 +1,43 @@
|
||||
# Whether dynamic dns is enabled
|
||||
matrix_dynamic_dns_enabled: true
|
||||
matrix_dynamic_dns_enabled: false
|
||||
|
||||
# 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'
|
||||
matrix_dynamic_dns_mode: 'daemon'
|
||||
|
||||
# The dynamic dns daemon interval
|
||||
matrix_dynamic_dns_daemon_interval: '300'
|
||||
|
||||
# The docker container to use when in daemon mode
|
||||
matrix_dynamic_dns_docker_image: 'linuxserver/ddclient'
|
||||
|
||||
# The image to force pull
|
||||
matrix_dynamic_dns_docker_image_force_pull: "{{ matrix_dynamic_dns_docker_image.endswith(':latest') }}"
|
||||
|
||||
# List of extra arguments to pass to the ontainer daemon mode
|
||||
matrix_dynamic_dns_container_extra_arguments: []
|
||||
|
||||
# List of wanted services when running in daemon mode
|
||||
matrix_dynamic_dns_systemd_wanted_services_list: []
|
||||
|
||||
# List of required services when running in daemon mode
|
||||
matrix_dynamic_dns_systemd_required_services_list: ['docker.service']
|
||||
|
||||
# Build the container from source when running in daemon mode
|
||||
matrix_dynamic_dns_container_image_self_build: false
|
||||
|
||||
# Config paths
|
||||
matrix_dynamic_dns_base_path: "{{ matrix_base_data_path }}/dynamic-dns"
|
||||
matrix_dynamic_dns_config_path: "{{ matrix_dynamic_dns_base_path }}/config"
|
||||
matrix_dynamic_dns_docker_src_files_path: "{{ matrix_dynamic_dns_base_path }}/docker-src"
|
||||
|
||||
# Config options
|
||||
matrix_dynamic_dns_use: "web"
|
||||
matrix_dynamic_dns_static: false
|
||||
matrix_dynamic_dns_custom: false
|
||||
matrix_dynamic_dns_zone: ""
|
||||
matrix_dynamic_dns_ttl: ""
|
||||
matrix_dynamic_dns_mx: ""
|
||||
matrix_dynamic_dns_wildcard: false
|
||||
matrix_dynamic_dns_protocol: 'dyndns2'
|
||||
matrix_dynamic_dns_provider: 'domains.google.com'
|
||||
matrix_dynamic_dns_domain: '{{ matrix_domain }}'
|
||||
|
@ -1,3 +1,7 @@
|
||||
- set_fact:
|
||||
matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['ddclient'] }}"
|
||||
when: "matrix_dynamic_dns_enabled|bool"
|
||||
when: "matrix_dynamic_dns_enabled|bool and matrix_dynamic_dns_mode == 'dhcp'"
|
||||
|
||||
- set_fact:
|
||||
matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-dynamic-dns'] }}"
|
||||
when: "matrix_dynamic_dns_enabled|bool and matrix_dynamic_dns_mode == 'daemon'"
|
||||
|
@ -0,0 +1,59 @@
|
||||
---
|
||||
|
||||
- name: Ensure Dynamic DNS image is pulled
|
||||
docker_image:
|
||||
name: "{{ matrix_dynamic_dns_docker_image }}"
|
||||
source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}"
|
||||
force_source: "{{ matrix_dynamic_dns_docker_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
|
||||
force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_dynamic_dns_docker_image_force_pull }}"
|
||||
when: matrix_dynamic_dns_enabled|bool and not matrix_dynamic_dns_container_image_self_build
|
||||
|
||||
- name: Ensure Dynamic DNS paths exist
|
||||
file:
|
||||
path: "{{ item.path }}"
|
||||
state: directory
|
||||
mode: 0750
|
||||
owner: "{{ matrix_user_username }}"
|
||||
group: "{{ matrix_user_groupname }}"
|
||||
with_items:
|
||||
- { path: "{{ matrix_dynamic_dns_base_path }}", when: true }
|
||||
- { path: "{{ matrix_dynamic_dns_config_path }}", when: true }
|
||||
- { path: "{{ matrix_dynamic_dns_docker_src_files_path }}", when: "{{ matrix_dynamic_dns_container_image_self_build }}" }
|
||||
when: matrix_dynamic_dns_enabled|bool and item.when|bool
|
||||
|
||||
- name: Ensure Dynamic DNS repository is present on self build
|
||||
git:
|
||||
repo: https://github.com/linuxserver/docker-ddclient.git
|
||||
dest: "{{ matrix_dynamic_dns_docker_src_files_path }}"
|
||||
force: "yes"
|
||||
when: "matrix_dynamic_dns_enabled|bool and matrix_dynamic_dns_container_image_self_build"
|
||||
|
||||
- name: Ensure Dynamic DNS Docker image is built
|
||||
docker_image:
|
||||
name: "{{ matrix_dynamic_dns_docker_image }}"
|
||||
source: build
|
||||
build:
|
||||
dockerfile: Dockerfile
|
||||
path: "{{ matrix_dynamic_dns_docker_src_files_path }}"
|
||||
pull: yes
|
||||
when: "matrix_dynamic_dns_enabled|bool and matrix_dynamic_dns_container_image_self_build"
|
||||
|
||||
- name: Ensure Dynamic DNS ddclient.conf installed
|
||||
template:
|
||||
src: "{{ role_path }}/templates/ddclient.conf.j2"
|
||||
dest: "{{ matrix_dynamic_dns_config_path }}/ddclient.conf"
|
||||
mode: 0644
|
||||
owner: "{{ matrix_user_username }}"
|
||||
group: "{{ matrix_user_groupname }}"
|
||||
|
||||
- name: Ensure matrix-dynamic-dns.service installed
|
||||
template:
|
||||
src: "{{ role_path }}/templates/systemd/matrix-dynamic-dns.service.j2"
|
||||
dest: "/etc/systemd/system/matrix-dynamic-dns.service"
|
||||
mode: 0644
|
||||
register: matrix_dynamic_dns_systemd_service_result
|
||||
|
||||
- name: Ensure systemd reloaded after matrix-dynamic-dns.service installation
|
||||
service:
|
||||
daemon_reload: yes
|
||||
when: "matrix_dynamic_dns_systemd_service_result.changed"
|
@ -0,0 +1,24 @@
|
||||
---
|
||||
|
||||
- name: Check existence of matrix-dynamic-dns service
|
||||
stat:
|
||||
path: "{{ systemd_path }}m/matrix-dynamic-dns.service"
|
||||
register: matrix_dynamic_dns_service_stat
|
||||
|
||||
- name: Ensure matrix-dynamic-dns is stopped
|
||||
service:
|
||||
name: matrix-dynamic-dns
|
||||
state: stopped
|
||||
daemon_reload: yes
|
||||
when: "matrix_dynamic_dns_service_stat.stat.exists"
|
||||
|
||||
- name: Ensure matrix-dynamic-dns.service doesn't exist
|
||||
file:
|
||||
path: "{{ systemd_path }}m/matrix-dynamic-dns.service"
|
||||
state: absent
|
||||
when: "matrix_dynamic_dns_service_stat.stat.exists"
|
||||
|
||||
- name: Ensure systemd reloaded after matrix-dynamic-dns.service removal
|
||||
service:
|
||||
daemon_reload: yes
|
||||
when: "matrix_dynamic_dns_service_stat.stat.exists"
|
@ -1,7 +1,17 @@
|
||||
protocol={{ matrix_dynamic_dns_protocol }}
|
||||
use=web
|
||||
{% if matrix_dynamic_dns_mode == "daemon" %}}
|
||||
daemon={{ matrix_dynamic_dns_daemon_interval }}
|
||||
syslog=no
|
||||
pid=/var/run/ddclient/ddclient.pid {% endif %}
|
||||
ssl=yes
|
||||
server={{ matrix_dynamic_dns_provider }}
|
||||
login='{{ matrix_dynamic_dns_username }}'
|
||||
password='{{ matrix_dynamic_dns_password }}'
|
||||
{{ matrix_domain }}
|
||||
use={{ matrix_dynamic_dns_use }}
|
||||
protocol={{ matrix_dynamic_dns_protocol }}
|
||||
server={{ matrix_dynamic_dns_provider }} {% if matrix_dynamic_dns_username %}
|
||||
login='{{ matrix_dynamic_dns_username }}' {% endif %} {% if matrix_dynamic_dns_username %}
|
||||
password='{{ matrix_dynamic_dns_password }}' {% endif %} {% if matrix_dynamic_dns_static %}
|
||||
static=yes {% endif %} {% if matrix_dynamic_dns_custom %}
|
||||
custom=yes {% endif %} {% if matrix_dynamic_dns_zone %}
|
||||
zone={{ matrix_dynamic_dns_zone }} {% endif %} {% if matrix_dynamic_dns_ttl %}
|
||||
ttl={{ matrix_dynamic_dns_ttl }} {% endif %} {% if matrix_dynamic_dns_mx %}
|
||||
mx={{ matrix_dynamic_dns_mx }} {% endif %} {% if matrix_dynamic_dns_wildcard %}
|
||||
wildcard=yes {% endif %}
|
||||
{{ matrix_dynamic_dns_domain }}
|
||||
|
@ -1,4 +0,0 @@
|
||||
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 }}"
|
@ -0,0 +1,41 @@
|
||||
#jinja2: lstrip_blocks: "True"
|
||||
[Unit]
|
||||
Description=Matrix Dynamic DNS
|
||||
{% for service in matrix_dynamic_dns_systemd_required_services_list %}
|
||||
Requires={{ service }}
|
||||
After={{ service }}
|
||||
{% endfor %}
|
||||
{% for service in matrix_dynamic_dns_systemd_wanted_services_list %}
|
||||
Wants={{ service }}
|
||||
{% endfor %}
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
ExecStartPre=-{{ matrix_host_command_docker }} kill matrix-dynamic-dns
|
||||
ExecStartPre=-{{ matrix_host_command_docker }} rm matrix-dynamic-dns
|
||||
|
||||
# Intentional delay, so that the homeserver (we likely depend on) can manage to start.
|
||||
ExecStartPre={{ matrix_host_command_sleep }} 5
|
||||
|
||||
ExecStart={{ matrix_host_command_docker }} run --rm --name matrix-dynamic-dns \
|
||||
--log-driver=none \
|
||||
--user={{ matrix_user_uid }}:{{ matrix_user_gid }} \
|
||||
--cap-drop=ALL \
|
||||
--network={{ matrix_docker_network }} \
|
||||
-e PUID={{ matrix_user_uid }} \
|
||||
-e PGID={{ matrix_user_gid }} \
|
||||
-e CONFIG_PATH=/config/config.yaml \
|
||||
-v {{ matrix_dynamic_dns_config_path }}:/config:z \
|
||||
{% for arg in matrix_dynamic_dns_container_extra_arguments %}
|
||||
{{ arg }} \
|
||||
{% endfor %}
|
||||
{{ matrix_dynamic_dns_docker_image }}
|
||||
|
||||
ExecStop=-{{ matrix_host_command_docker }} kill matrix-dynamic-dns
|
||||
ExecStop=-{{ matrix_host_command_docker }} rm matrix-dynamic-dns
|
||||
Restart=always
|
||||
RestartSec=30
|
||||
SyslogIdentifier=matrix-dynamic-dns
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
Loading…
Reference in new issue