Skip to content

Commit 0a1abe5

Browse files
committed
fix random uppercase value in openvpn API
1 parent 7c202b7 commit 0a1abe5

File tree

4 files changed

+16
-4
lines changed

4 files changed

+16
-4
lines changed

docs/source/modules/openvpn.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ ansibleguy.opnsense.openvpn_server
6262
"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)."
6363
"auth_mode","list","false","\-","authentication_mode, auth_source","Select authentication methods to use, leave empty if no challenge response authentication is needed."
6464
"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."
65-
"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."
65+
"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."
6666
"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."
6767
"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."
6868
"domain","string","false","\-","dns_domain","Set Connection-specific DNS Suffix."
@@ -107,7 +107,7 @@ ansibleguy.opnsense.openvpn_client
107107
"password","string","false","\-","pwd","Password belonging to the user specified above"
108108
"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"
109109
"network_remote","list","false","\-","remote, net_remote, route","Remote networks for the server, add route to routing table after connection is established"
110-
"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."
110+
"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."
111111
"mtu","integer","false","\-","tun_mtu","Take the TUN device MTU to be tun-mtu and derive the link MTU from it."
112112
"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."
113113
"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."

plugins/module_utils/defaults/openvpn.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
description='Various less frequently used yes/no options which can be set for this instance.',
8585
choices=[
8686
'client-to-client', 'duplicate-cn', 'passtos', 'persist-remote-ip', 'route-nopull', 'route-noexec',
87-
'remote-random',
87+
'remote-random', 'float',
8888
],
8989
),
9090
mtu=dict(

plugins/module_utils/main/openvpn_client.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ def check(self) -> None:
8383
"You need to either provide a 'certificate' or 'ca' to create an openvpn-client!"
8484
)
8585

86-
8786
self._base_check()
8887

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

107106
if self.p['state'] == 'present':
107+
if 'before' in self.r['diff'] and 'mode' in self.r['diff']['before']:
108+
self.r['diff']['before']['mode'] = self.r['diff']['before']['mode'].lower()
109+
self.instance['mode'] = self.r['diff']['before']['mode']
110+
108111
self.r['diff']['after'] = self.b.build_diff(data=self.p)
112+
self.r['changed'] = self.r['diff']['before'] != self.r['diff']['after']
113+

plugins/module_utils/main/openvpn_server.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ def check(self) -> None:
9494
self.p['role'] = 'server'
9595

9696
if self.p['state'] == 'present':
97+
self.p['mode'] = self.p['mode'].upper()
98+
9799
validate_int_fields(module=self.m, data=self.p, field_minmax=self.INT_VALIDATIONS)
98100

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

136138
if self.p['state'] == 'present':
139+
if 'before' in self.r['diff'] and 'mode' in self.r['diff']['before']:
140+
self.r['diff']['before']['mode'] = self.r['diff']['before']['mode'].lower()
141+
self.instance['mode'] = self.r['diff']['before']['mode']
142+
137143
self.r['diff']['after'] = self.b.build_diff(data=self.p)
144+
self.r['changed'] = self.r['diff']['before'] != self.r['diff']['after']

0 commit comments

Comments
 (0)