From 208e8efcc9ffc3e43525e5cf81d52381f624a237 Mon Sep 17 00:00:00 2001 From: Dan Langille Date: Fri, 7 Mar 2025 14:44:14 +0000 Subject: [PATCH 1/8] Optionally backup configuration file on install Allow for root:wheel permissions on FreeBSD Add some debug messages Add full pathname to template Optionally specify cache file in configuration --- defaults/main.yml | 6 ++++++ tasks/configure.yml | 26 ++++++++++++++++++-------- tasks/setup-FreeBSD.yml | 5 +++++ templates/ddclient.conf.j2 | 6 +++++- templates/ddclient.service.j2 | 2 +- 5 files changed, 35 insertions(+), 10 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index 02fd73a..0b92b51 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -8,6 +8,8 @@ ddclient_daemon: 300 ddclient_install_from_source: false ddclient_ssl: 'yes' +ddclient_backup: 'no' + ddclient_configs: - protocol: dnspark use: null @@ -20,3 +22,7 @@ ddclient_configs: password: password hosts: - host + +ddclient_owner: root +ddclient_group: root +ddclient_specify_cache: false diff --git a/tasks/configure.yml b/tasks/configure.yml index 294e659..fd146e4 100644 --- a/tasks/configure.yml +++ b/tasks/configure.yml @@ -3,33 +3,43 @@ ansible.builtin.file: path: "{{ __ddclient_configuration_directory }}" state: directory - owner: root - group: root + owner: "{{ ddclient_owner }}" + group: "{{ ddclient_group }}" mode: 0750 - 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 diff --git a/tasks/setup-FreeBSD.yml b/tasks/setup-FreeBSD.yml index aa932e4..4172e93 100644 --- a/tasks/setup-FreeBSD.yml +++ b/tasks/setup-FreeBSD.yml @@ -2,3 +2,8 @@ community.general.pkgng: name: ddclient state: present + +- ansible.builtin.set_fact: + ddclient_owner: "root" + ddclient_group: "wheel" + __ddclient_configuration_directory: /usr/local/etc/ diff --git a/templates/ddclient.conf.j2 b/templates/ddclient.conf.j2 index 2ef6664..4b0216f 100644 --- a/templates/ddclient.conf.j2 +++ b/templates/ddclient.conf.j2 @@ -1,9 +1,13 @@ #jinja2: trim_blocks: True -# {{ ansible_managed }} +# {{ ansible_managed }}. Template: {{ template_fullpath }} daemon={{ ddclient_daemon }} ssl={{ ddclient_ssl }} syslog=yes +{% 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 }} diff --git a/templates/ddclient.service.j2 b/templates/ddclient.service.j2 index 7469de3..bc8f475 100644 --- a/templates/ddclient.service.j2 +++ b/templates/ddclient.service.j2 @@ -1,4 +1,4 @@ -# {{ ansible_managed }} +# {{ ansible_managed }}. Template: {{ template_fullpath }} [Unit] Description=Dynamic DNS Update Client From 3511d734ab1abf06f7c05b1b9ae6bda15bf59171 Mon Sep 17 00:00:00 2001 From: Dan Langille Date: Fri, 7 Mar 2025 15:21:54 +0000 Subject: [PATCH 2/8] Correct the chmod for the config directory on FreeBSD If you chmod 0750 /usr/local/etc/, many things will be unhappy --- defaults/main.yml | 1 + tasks/configure.yml | 2 +- tasks/setup-FreeBSD.yml | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/defaults/main.yml b/defaults/main.yml index 0b92b51..5702958 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -26,3 +26,4 @@ ddclient_configs: ddclient_owner: root ddclient_group: root ddclient_specify_cache: false +__ddclient_configuration_directory_mode: 0750 diff --git a/tasks/configure.yml b/tasks/configure.yml index fd146e4..1d79c6e 100644 --- a/tasks/configure.yml +++ b/tasks/configure.yml @@ -5,7 +5,7 @@ state: directory owner: "{{ ddclient_owner }}" group: "{{ ddclient_group }}" - mode: 0750 + mode: "{{ __ddclient_configuration_directory_mode }}" - name: Create configuration file ansible.builtin.template: diff --git a/tasks/setup-FreeBSD.yml b/tasks/setup-FreeBSD.yml index 4172e93..65a1251 100644 --- a/tasks/setup-FreeBSD.yml +++ b/tasks/setup-FreeBSD.yml @@ -7,3 +7,4 @@ ddclient_owner: "root" ddclient_group: "wheel" __ddclient_configuration_directory: /usr/local/etc/ + __ddclient_configuration_directory_mode: 0755 From 1bb3a6d47b0a0898724f9a65922b7c30f8be0da6 Mon Sep 17 00:00:00 2001 From: Dan Langille Date: Fri, 7 Mar 2025 16:38:17 +0000 Subject: [PATCH 3/8] Include ttl if specified. --- templates/ddclient.conf.j2 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/templates/ddclient.conf.j2 b/templates/ddclient.conf.j2 index 4b0216f..0bbc10a 100644 --- a/templates/ddclient.conf.j2 +++ b/templates/ddclient.conf.j2 @@ -28,6 +28,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(', ')}} From 9045b830c053252eaaa021ce139e5d027de0e41b Mon Sep 17 00:00:00 2001 From: Dan Langille Date: Wed, 11 Mar 2026 18:35:19 +0000 Subject: [PATCH 4/8] Adjust default installation directory for FreeBSD It is now /usr/local/etc/ddclient/ See details at https://github.com/ddclient/ddclient/releases/tag/v4.0.0 --- tasks/setup-FreeBSD.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/setup-FreeBSD.yml b/tasks/setup-FreeBSD.yml index 65a1251..fcbf5b6 100644 --- a/tasks/setup-FreeBSD.yml +++ b/tasks/setup-FreeBSD.yml @@ -6,5 +6,5 @@ - ansible.builtin.set_fact: ddclient_owner: "root" ddclient_group: "wheel" - __ddclient_configuration_directory: /usr/local/etc/ + __ddclient_configuration_directory: /usr/local/etc/ddclient __ddclient_configuration_directory_mode: 0755 From a1975bf616ce685301eaa8a94baf8e76314d0099 Mon Sep 17 00:00:00 2001 From: Dan Langille Date: Fri, 13 Mar 2026 17:22:59 +0000 Subject: [PATCH 5/8] launch from rc.d --- tasks/setup-FreeBSD.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tasks/setup-FreeBSD.yml b/tasks/setup-FreeBSD.yml index fcbf5b6..5a953b2 100644 --- a/tasks/setup-FreeBSD.yml +++ b/tasks/setup-FreeBSD.yml @@ -8,3 +8,19 @@ 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: set ddclient flags + sysrc: + name: ddclient_flags + state: present + value: " --syslog --usev4=ifv4 --ifv4=igc0 --daemon=0 --verbose --facility=local3 --pid=/var/run/ddclient.pid" + dest: /etc/rc.conf.d/ddclient + tags: ddclient From 660bf6d6953d138972fd6ef624eefcf520a2616d Mon Sep 17 00:00:00 2001 From: Dan Langille Date: Fri, 13 Mar 2026 17:24:07 +0000 Subject: [PATCH 6/8] do not use ddclient_flags, put that stuff in ddclient.conf instead --- tasks/setup-FreeBSD.yml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/tasks/setup-FreeBSD.yml b/tasks/setup-FreeBSD.yml index 5a953b2..c52d5c2 100644 --- a/tasks/setup-FreeBSD.yml +++ b/tasks/setup-FreeBSD.yml @@ -16,11 +16,3 @@ value: "YES" dest: /etc/rc.conf.d/ddclient tags: ddclient - -- name: set ddclient flags - sysrc: - name: ddclient_flags - state: present - value: " --syslog --usev4=ifv4 --ifv4=igc0 --daemon=0 --verbose --facility=local3 --pid=/var/run/ddclient.pid" - dest: /etc/rc.conf.d/ddclient - tags: ddclient From 766f0652f8ddf4d8b64da0a7f9b1beeaa41d0027 Mon Sep 17 00:00:00 2001 From: Dan Langille Date: Fri, 13 Mar 2026 17:51:13 +0000 Subject: [PATCH 7/8] Add newsyslog.conf file Adjust templlate for ddclient-4.0 --- templates/ddclient_newsyslog.j2 | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 templates/ddclient_newsyslog.j2 diff --git a/templates/ddclient_newsyslog.j2 b/templates/ddclient_newsyslog.j2 new file mode 100644 index 0000000..3f3a7a4 --- /dev/null +++ b/templates/ddclient_newsyslog.j2 @@ -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 From 08d0db26ba3db41d000e9ec7f49b4d0e431eabd8 Mon Sep 17 00:00:00 2001 From: Dan Langille Date: Sat, 14 Mar 2026 11:55:27 +0000 Subject: [PATCH 8/8] Adjust for ddclient-4.0.0 Now using usev4 instad of use And usev4 for the IP address --- defaults/main.yml | 6 ++++++ tasks/setup-FreeBSD.yml | 4 ++++ templates/ddclient.conf.j2 | 10 ++++++++-- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index 5702958..20abfd2 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -27,3 +27,9 @@ 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 diff --git a/tasks/setup-FreeBSD.yml b/tasks/setup-FreeBSD.yml index c52d5c2..7cad990 100644 --- a/tasks/setup-FreeBSD.yml +++ b/tasks/setup-FreeBSD.yml @@ -16,3 +16,7 @@ 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 diff --git a/templates/ddclient.conf.j2 b/templates/ddclient.conf.j2 index 0bbc10a..6c76f48 100644 --- a/templates/ddclient.conf.j2 +++ b/templates/ddclient.conf.j2 @@ -4,13 +4,19 @@ 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 %}