Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ ddclient_daemon: 300
ddclient_install_from_source: false
ddclient_ssl: 'yes'

ddclient_backup: 'no'

ddclient_configs:
- protocol: dnspark
use: null
Expand All @@ -20,3 +22,14 @@ ddclient_configs:
password: password
hosts:
- host

ddclient_owner: root
ddclient_group: root
ddclient_specify_cache: false
__ddclient_configuration_directory_mode: 0750


newsyslog_config_dir: /usr/local/etc/newsyslog.conf.d
ddclient_newsyslog_template: ddclient_newsyslog
ddclient_newsyslog_file: ddclient
ddclient_newsyslog_count: 50
28 changes: 19 additions & 9 deletions tasks/configure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,43 @@
ansible.builtin.file:
path: "{{ __ddclient_configuration_directory }}"
state: directory
owner: root
group: root
mode: 0750
owner: "{{ ddclient_owner }}"
group: "{{ ddclient_group }}"
mode: "{{ __ddclient_configuration_directory_mode }}"

- name: Create configuration file
ansible.builtin.template:
src: "{{ ddclient_configuration_template }}"
dest: "{{ __ddclient_configuration_location }}"
owner: root
group: root
owner: "{{ ddclient_owner }}"
group: "{{ ddclient_group }}"
backup: "{{ ddclient_backup }}"
mode: 0600

- name: Create the cache directory
ansible.builtin.file:
path: "{{ __ddclient_cache_directory }}"
state: directory
owner: root
group: root
owner: "{{ ddclient_owner }}"
group: "{{ ddclient_group }}"
mode: '0750'

- name: Create the systemd file
ansible.builtin.template:
src: "{{ ddclient_service_template }}"
dest: "{{ __ddclient_service_file }}"
owner: root
group: root
owner: "{{ ddclient_owner }}"
group: "{{ ddclient_group }}"
mode: 0644
when: ansible_os_family != 'FreeBSD' and not ddclient_install_from_source
notify:
- Disable_Service_DDClient
- Enable_Service_DDClient

- name: List some items
ansible.builtin.debug:
msg:
- "__ddclient_configuration_directory: {{ __ddclient_configuration_directory }}"
- "__ddclient_configuration_location: {{ __ddclient_configuration_location }}"
- "__ddclient_cache_director: {{ __ddclient_cache_directory }}"
tags: debug
18 changes: 18 additions & 0 deletions tasks/setup-FreeBSD.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,21 @@
community.general.pkgng:
name: ddclient
state: present

- ansible.builtin.set_fact:
ddclient_owner: "root"
ddclient_group: "wheel"
__ddclient_configuration_directory: /usr/local/etc/ddclient
__ddclient_configuration_directory_mode: 0755

- name: enable ddclient
sysrc:
name: ddclient_enable
state: present
value: "YES"
dest: /etc/rc.conf.d/ddclient
tags: ddclient

- name: install newsyslog.conf file
template: src={{ ddclient_newsyslog_template }}.j2 dest={{ newsyslog_config_dir }}/{{ ddclient_newsyslog_file }}.conf owner=root group=wheel mode=0644 backup=yes
tags: ddclient,newsyslog
19 changes: 16 additions & 3 deletions templates/ddclient.conf.j2
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
#jinja2: trim_blocks: True
# {{ ansible_managed }}
# {{ ansible_managed }}. Template: {{ template_fullpath }}

daemon={{ ddclient_daemon }}
ssl={{ ddclient_ssl }}
syslog=yes
verbose
facility=local3
pid=/var/run/ddclient.pid
{% if ddclient_specify_cache %}
cache={{ __ddclient_cache_directory }}/ddclient.cache
{% endif %}

{% for config in ddclient_configs %}
{% if config.use is defined and config.use %}
use={{ config.use }}
{% if config.usev4 is defined and config.usev4 %}
usev4={{ config.usev4 }}
{% endif %}
{% if config.ifv4 is defined and config.ifv4 %}
ifv4={{ config.ifv4 }}
{% endif %}
protocol={{ config.protocol }}
{% if config.server is defined and config.server %}
Expand All @@ -24,6 +34,9 @@ mxpri={{ config.mxpri }},
{% if config.zone is defined and config.zone %}
zone={{ config.zone }}
{% endif %}
{% if config.ttl is defined and config.ttl %}
ttl={{ config.ttl }}
{% endif %}
login={{ config.login }}
password={{ config.password }}
{{ config.hosts|join(', ')}}
Expand Down
2 changes: 1 addition & 1 deletion templates/ddclient.service.j2
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# {{ ansible_managed }}
# {{ ansible_managed }}. Template: {{ template_fullpath }}

[Unit]
Description=Dynamic DNS Update Client
Expand Down
5 changes: 5 additions & 0 deletions templates/ddclient_newsyslog.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Only .conf files /usr/local/etc/newsyslog.conf.d/ are pulled in by newsyslog
#

# logfilename [owner:group] mode count size when flags [/pid_file] [sig_num]
/var/log/ddclient.log root:logcheck 640 {{ ddclient_newsyslog_count }} * $D0 B