Skip to content

Commit

Permalink
#63 wip ... openvpn overwrite config
Browse files Browse the repository at this point in the history
  • Loading branch information
zerwes committed Apr 17, 2024
1 parent 2f051e9 commit cf2c5dd
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
9 changes: 9 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,12 @@ opn_openvpn_instances_defaults:
verb: 3
topology: subnet
role: server

# defaults for opn_openvpn_instances
opn_openvpn_overwrites_defaults:
enabled: 1
block: 0
push_reset: 0
register_dns: 0

...
10 changes: 10 additions & 0 deletions tasks/openvpn.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,16 @@
# push "dhcp-option DOMAIN abc.example.net"
# push "dhcp-option DOMAIN xyz.example.net"

- name: OpenVPN Overwrites configuration
ansible.builtin.include_tasks: openvpnoverwrite.yml
vars:
uuid: "{{ overwrite.key }}"
overwritecfg: "{{ overwrite.value | combine(opn_openvpn_overwrites_defaults) }}"
with_dict:
- "{{ opn_openvpn_overwrites | default({}) }}"
loop_control:
loop_var: overwrite

- name: OpenVPN Instances configuration
ansible.builtin.include_tasks: openvpninstance.yml
vars:
Expand Down
27 changes: 27 additions & 0 deletions tasks/openvpnoverwrite.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---

- name: OpenVPN Overwrite settings
delegate_to: localhost
community.general.xml:
path: "{{ local_config_path }}"
xpath: "/opnsense/OPNsense/OpenVPN/Overwrites/Overwrite[@uuid='{{ uuid }}']/{{ item.key }}"
value: "{{ item.value }}"
pretty_print: true
when:
- item.key not in ['dns_domain_search', 'dns_servers', 'ntp_servers', 'wins_servers'] or item.value is string
with_dict:
- "{{ overwritecfg | default({}) }}"

- name: OpenVPN Overwrite settings with list elements
delegate_to: localhost
community.general.xml:
path: "{{ local_config_path }}"
xpath: "/opnsense/OPNsense/OpenVPN/Overwrites/Overwrite[@uuid='{{ uuid }}']/{{ item.key }}"
value: "{{ item.value | join(',') }}"
pretty_print: true
when:
- item.key in ['dns_domain_search', 'dns_servers', 'ntp_servers', 'wins_servers'] and not item.value is string
with_dict:
- "{{ overwritecfg | default({}) }}"

...

0 comments on commit cf2c5dd

Please sign in to comment.