From 45c9dacac842cfc3323c77c821a220d4cbfd4745 Mon Sep 17 00:00:00 2001 From: Farhad Nateghi <56291706+fnateghi@users.noreply.github.com> Date: Thu, 12 Sep 2024 15:15:50 +0200 Subject: [PATCH] add example vars into dyndnstask,add dyndns to test.yml, modified handler and add fake handler --- tasks/dyndns.yml | 62 +++++++++++++++++++++++------- test/dyndns-test-expect.xml | 3 ++ test/dyndns-test.yml | 49 ++++++++++++++++++++++++ test/test-dyndn.yml | 72 ----------------------------------- test/test-dyndns-expected.xml | 34 ----------------- test/test.yml | 1 + 6 files changed, 102 insertions(+), 119 deletions(-) create mode 100644 test/dyndns-test-expect.xml create mode 100644 test/dyndns-test.yml delete mode 100644 test/test-dyndn.yml delete mode 100644 test/test-dyndns-expected.xml diff --git a/tasks/dyndns.yml b/tasks/dyndns.yml index fb3a0b7..1ab57e6 100644 --- a/tasks/dyndns.yml +++ b/tasks/dyndns.yml @@ -1,15 +1,51 @@ --- - -- name: DynDNS - remove DynDNS - delegate_to: localhost - community.general.xml: - path: "{{ local_config_path }}" - xpath: /opnsense/OPNsense/DynDNS{{ item }} - state: absent - pretty_print: true - notify: register dyndns - with_items: "{{ opn_dyndns_accounts_remove }}" - when: opn_dyndns_accouts_remove is defined +# +#opn_dyndns_general: +# - key: enabled +# value: "1" +# - key: verbose +# value: "0" +# - key: allowipv6nano +# value: "0" +# - key: daemon_delay +# value: "300" +# - key: backend +# value: "opnsense" +#opn_dyndns_accounts: +# - uuid: "8e4627c4-21ff-4252-a331-3d1adee0a023" +# settings: +# - key: enabled +# value: "1" +# - key: service +# value: "testservice" +# - key: protocol +# value: "" +# - key: server +# value: "" +# - key: username +# value: "user" +# - key: password +# value: "pass" +# - key: resourceId +# value: "" +# - key: hostnames +# value: "all.ddnskey.com" +# - key: wildcard +# value: "0" +# - key: zone +# value: "" +# - key: checkip +# value: "web_noip-ipv4" +# - key: checkip_timeout +# value: "10" +# - key: force_ssl +# value: "1" +# - key: ttl +# value: "300" +# - key: interface +# value: "wan" +# - key: description +# value: "dyndns-description" - name: DynDNS - Update general DynDNS settings delegate_to: localhost @@ -19,7 +55,7 @@ value: "{{ item.value }}" state: present pretty_print: true - notify: register dyndns + notify: restart dyndns loop: "{{ opn_dyndns_general }}" when: - opn_dyndns_general is defined @@ -32,7 +68,7 @@ value: "{{ item.1.value }}" state: present pretty_print: true - notify: register dyndns + notify: restart dyndns with_subelements: - "{{ opn_dyndns_accounts }}" - settings diff --git a/test/dyndns-test-expect.xml b/test/dyndns-test-expect.xml new file mode 100644 index 0000000..0cfeed6 --- /dev/null +++ b/test/dyndns-test-expect.xml @@ -0,0 +1,3 @@ + + + diff --git a/test/dyndns-test.yml b/test/dyndns-test.yml new file mode 100644 index 0000000..d5e65c8 --- /dev/null +++ b/test/dyndns-test.yml @@ -0,0 +1,49 @@ +--- +test_name: simple filter test + +opn_dyndns_general: + - key: enabled + value: "1" + - key: verbose + value: "0" + - key: allowipv6nano + value: "0" + - key: daemon_delay + value: "300" + - key: backend + value: "opnsense" +opn_dyndns_accounts: + - uuid: "8e4627c4-21ff-4252-a331-3d1adee0a023" + settings: + - key: enabled + value: "1" + - key: service + value: "noip" + - key: protocol + value: "" + - key: server + value: "" + - key: username + value: "" + - key: password + value: "user" + - key: resourceId + value: "pass" + - key: hostnames + value: "all.ddnskey.com" + - key: wildcard + value: "0" + - key: zone + value: "" + - key: checkip + value: "web_noip-ipv4" + - key: checkip_timeout + value: "10" + - key: force_ssl + value: "1" + - key: ttl + value: "300" + - key: interface + value: "wan" + - key: description + value: "dyndns-description" diff --git a/test/test-dyndn.yml b/test/test-dyndn.yml deleted file mode 100644 index 4747ba2..0000000 --- a/test/test-dyndn.yml +++ /dev/null @@ -1,72 +0,0 @@ ---- -- name: Update DynDNS Configuration XML - hosts: localhost - vars: - opn_dyndns_general: - - key: enabled - value: "1" - - key: verbose - value: "0" - - key: allowipv6 - value: "0" - - key: daemon_delay - value: "300" - - key: backend - value: "opnsense" - opn_dyndns_accounts: - - uuid: "8e4627c4-21ff-4252-a331-3d1adee0a023" - settings: - - key: enabled - value: "1" - - key: service - value: "noip" - - key: protocol - value: "" - - key: server - value: "" - - key: username - value: "" - - key: password - value: "" - - key: resourceId - value: "" - - key: hostnames - value: "all.ddnskey.com" - - key: wildcard - value: "0" - - key: zone - value: "" - - key: checkip - value: "web_noip-ipv4" - - key: checkip_timeout - value: "10" - - key: force_ssl - value: "1" - - key: ttl - value: "300" - - key: interface - value: "wan" - - key: description - value: "" - tasks: - - name: Update general DynDNS settings - community.general.xml: - path: "{{ playbook_dir }}/dyndns-test-expected.xml" - xpath: "/opnsense/OPNSense/DynDNS/general/{{ item.key }}" - value: "{{ item.value }}" - state: present - pretty_print: true - loop: "{{ opn_dyndns_general }}" - delegate_to: localhost - - - name: Update account specific DynDNS settings - community.general.xml: - path: "{{ playbook_dir }}/dyndns-test-expected.xml" - xpath: "/opnsense/OPNSense/DynDNS/accounts/account[@uuid='{{ item.0.uuid }}']/{{ item.1.key }}" - value: "{{ item.1.value }}" - state: present - pretty_print: true - with_subelements: - - "{{ opn_dyndns_accounts }}" - - settings - delegate_to: localhost diff --git a/test/test-dyndns-expected.xml b/test/test-dyndns-expected.xml deleted file mode 100644 index f3fd03e..0000000 --- a/test/test-dyndns-expected.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - 1 - 0 - 0 - 300 - opnsense - - - - 1 - noip - - - - - - all.ddnskey.com - 0 - - web_noip-ipv4 - 10 - 1 - 300 - wan - rls-dyndns-noip - - - - - diff --git a/test/test.yml b/test/test.yml index 128fa79..3dac9e8 100644 --- a/test/test.yml +++ b/test/test.yml @@ -48,6 +48,7 @@ - ipsec - dnsserver - openvpn + - dyndns when: - test | default(_testtask) == _testtask - ansible.builtin.meta: flush_handlers