Skip to content

Commit 1d47dea

Browse files
authored
fix(frontend): conditionally apply httpclose default for http type only (#6)
The httpclose parameter had an unconditional default value of 'http-keep-alive' which caused validation to fail for https/tcp frontend types even when the user didn't specify the parameter. Now the default is only applied when type='http', allowing https and tcp frontends to work without explicitly setting httpclose.
1 parent 1fe1b07 commit 1d47dea

3 files changed

Lines changed: 8 additions & 4 deletions

File tree

docs/modules/pfsense_haproxy_frontend.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Manage pfSense HAProxy frontends
1414
| status | str | no | - | - | Frontend status (enabled/disabled). |
1515
| desc | str | no | - | - | Frontend description. |
1616
| type | str | no | http | http, https, tcp | Frontend type/mode. `http` - HTTP/HTTPS with offloading (SSL termination); `https` - SSL/HTTPS (TCP mode) for SNI-based routing; `tcp` - Plain TCP proxying for non-HTTP protocols. |
17-
| httpclose | str | no | http-keep-alive | http-keep-alive | HTTP close mode for connection handling. Only valid for `http` type frontends. |
17+
| httpclose | str | no | - | http-keep-alive | HTTP close mode for connection handling. Only valid for `http` type frontends. Defaults to `http-keep-alive` when `type=http` and not specified. |
1818
| backend_serverpool | str | no | - | - | Backend server pool to use. |
1919
| ssloffloadcert | str | no | - | - | SSL certificate for offloading. |
2020
| ssloffloadcert_type_search | str | no | descr | - | Field type to search for SSL certificate. |

plugins/module_utils/haproxy_frontend.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
status=dict(required=False, type='str'),
1515
desc=dict(required=False, type='str'),
1616
type=dict(default='http', choices=['http', 'https', 'tcp']),
17-
httpclose=dict(default='http-keep-alive', choices=['http-keep-alive']),
17+
httpclose=dict(required=False, choices=['http-keep-alive']),
1818
backend_serverpool=dict(required=False, type='str'),
1919
ssloffloadcert=dict(required=False, type='str'),
2020
ssloffloadcert_type_search=dict(default='descr', type='str'),
@@ -63,7 +63,11 @@ def _params_to_obj(self):
6363
self._get_ansible_param(obj, 'status')
6464
# Only add httpclose for HTTP mode (not https or tcp)
6565
if obj.get('type', 'http') == 'http':
66-
self._get_ansible_param(obj, 'httpclose')
66+
# Apply default if not explicitly set
67+
if self.params.get('httpclose') is None:
68+
obj['httpclose'] = 'http-keep-alive'
69+
else:
70+
self._get_ansible_param(obj, 'httpclose')
6771
self._get_ansible_param(obj, 'backend_serverpool')
6872
self._get_ansible_param(obj, 'max_connections')
6973

plugins/modules/pfsense_haproxy_frontend.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@
4747
description:
4848
- HTTP close mode for connection handling.
4949
- Only valid for C(http) type frontends.
50+
- Defaults to C(http-keep-alive) when C(type=http) and not specified.
5051
required: false
5152
type: str
5253
choices: ['http-keep-alive']
53-
default: 'http-keep-alive'
5454
backend_serverpool:
5555
description: Backend server pool to use.
5656
required: false

0 commit comments

Comments
 (0)