Skip to content

Commit

Permalink
fix random uppercase value in openvpn API
Browse files Browse the repository at this point in the history
  • Loading branch information
ansibleguy committed Aug 24, 2024
1 parent 7c202b7 commit 0a1abe5
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
4 changes: 2 additions & 2 deletions docs/source/modules/openvpn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ ansibleguy.opnsense.openvpn_server
"data_cipher_fallback","string","false","\-","cipher_fallback","One of: 'AES-256-GCM', 'AES-128-GCM', 'CHACHA20-POLY1305'. Configure a cipher that is used to fall back to if we could not determine which cipher the peer is willing to use. This option should only be needed to connect to peers that are running OpenVPN 2.3 or older versions, and have been configured with --enable-small (typically used on routers or other embedded devices)."
"auth_mode","list","false","\-","authentication_mode, auth_source","Select authentication methods to use, leave empty if no challenge response authentication is needed."
"auth_group","string","false","\-","group","Restrict access to users in the selected local group. Please be aware that other authentication backends will refuse to authenticate when using this option."
"options","list","false","\-","opts","One or multiple of: 'client-to-client', 'duplicate-cn', 'passtos', 'persist-remote-ip', 'route-nopull', 'route-noexec', 'remote-random'. Various less frequently used yes/no options which can be set for this instance."
"options","list","false","\-","opts","One or multiple of: 'client-to-client', 'duplicate-cn', 'passtos', 'float', 'persist-remote-ip', 'route-nopull', 'route-noexec', 'remote-random'. Various less frequently used yes/no options which can be set for this instance."
"push_options","list","false","\-","push_opts","One or multiple of: 'block-outside-dns', 'register-dns'. Various less frequently used yes/no options which can be pushed to the client for this instance."
"redirect_gateway","list","false","\-","redirect_gw, redir_gw","One or multiple of: 'local', 'autolocal', 'def1', 'bypass_dhcp', 'bypass_dns', 'block_local', 'ipv6', 'notipv4'. Automatically execute routing commands to cause all outgoing IP traffic to be redirected over the VPN."
"domain","string","false","\-","dns_domain","Set Connection-specific DNS Suffix."
Expand Down Expand Up @@ -107,7 +107,7 @@ ansibleguy.opnsense.openvpn_client
"password","string","false","\-","pwd","Password belonging to the user specified above"
"network_local","list","false","\-","local, net_local, push_route","These are the networks accessible on this host, these are pushed via route{-ipv6} clauses in OpenVPN to the client"
"network_remote","list","false","\-","remote, net_remote, route","Remote networks for the server, add route to routing table after connection is established"
"options","list","false","\-","opts","One or multiple of: 'client-to-client', 'duplicate-cn', 'passtos', 'persist-remote-ip', 'route-nopull', 'route-noexec', 'remote-random'. Various less frequently used yes/no options which can be set for this instance."
"options","list","false","\-","opts","One or multiple of: 'client-to-client', 'duplicate-cn', 'passtos', 'float', 'persist-remote-ip', 'route-nopull', 'route-noexec', 'remote-random'. Various less frequently used yes/no options which can be set for this instance."
"mtu","integer","false","\-","tun_mtu","Take the TUN device MTU to be tun-mtu and derive the link MTU from it."
"fragment_size","integer","false","\-","frag_size","Enable internal datagram fragmentation so that no UDP datagrams are sent which are larger than the specified byte size."
"mss_fix","boolean","false","false","mss","Announce to TCP sessions running over the tunnel that they should limit their send packet sizes such that after OpenVPN has encapsulated them, the resulting UDP packet size that OpenVPN sends to its peer will not exceed the recommended size."
Expand Down
2 changes: 1 addition & 1 deletion plugins/module_utils/defaults/openvpn.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
description='Various less frequently used yes/no options which can be set for this instance.',
choices=[
'client-to-client', 'duplicate-cn', 'passtos', 'persist-remote-ip', 'route-nopull', 'route-noexec',
'remote-random',
'remote-random', 'float',
],
),
mtu=dict(
Expand Down
7 changes: 6 additions & 1 deletion plugins/module_utils/main/openvpn_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ def check(self) -> None:
"You need to either provide a 'certificate' or 'ca' to create an openvpn-client!"
)


self._base_check()

if not is_unset(self.p['ca']):
Expand All @@ -105,4 +104,10 @@ def check(self) -> None:
)

if self.p['state'] == 'present':
if 'before' in self.r['diff'] and 'mode' in self.r['diff']['before']:
self.r['diff']['before']['mode'] = self.r['diff']['before']['mode'].lower()
self.instance['mode'] = self.r['diff']['before']['mode']

self.r['diff']['after'] = self.b.build_diff(data=self.p)
self.r['changed'] = self.r['diff']['before'] != self.r['diff']['after']

7 changes: 7 additions & 0 deletions plugins/module_utils/main/openvpn_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ def check(self) -> None:
self.p['role'] = 'server'

if self.p['state'] == 'present':
self.p['mode'] = self.p['mode'].upper()

validate_int_fields(module=self.m, data=self.p, field_minmax=self.INT_VALIDATIONS)

if is_unset(self.p['server_ip4']) and is_unset(self.p['server_ip6']):
Expand Down Expand Up @@ -134,4 +136,9 @@ def check(self) -> None:
)

if self.p['state'] == 'present':
if 'before' in self.r['diff'] and 'mode' in self.r['diff']['before']:
self.r['diff']['before']['mode'] = self.r['diff']['before']['mode'].lower()
self.instance['mode'] = self.r['diff']['before']['mode']

self.r['diff']['after'] = self.b.build_diff(data=self.p)
self.r['changed'] = self.r['diff']['before'] != self.r['diff']['after']

0 comments on commit 0a1abe5

Please sign in to comment.