Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add module to manage general Kea DHCP settings #136

Merged
merged 7 commits into from
Feb 7, 2025

Conversation

woelfle
Copy link

@woelfle woelfle commented Jan 6, 2025

Prior to this change, it was not possible to manage the general settings of the Kea DHCP server as it can be done in the Web UI via 'Services->Kea DHCP->Settings'. I.e. it was not possible to configure the interfaces on which the Kea should listen for DHCP requests.

This change adds a new module that allows to manage the general settings of the Kea DHCP server. The code can be found in
'plugins/modules/dhcp_general.py' and
'plugins/module_utils/dhcp_general.py'

Thomas Wölfle and others added 2 commits January 6, 2025 13:13
Prior to this change, it was not possible to manage the general settings
of the Kea DHCP server as it can be done in the Web UI via
'Services->Kea DHCP->Settings'. I.e. it was not possible to configure
the interfaces on which the Kea should listen for DHCP requests.

This change adds a new module that allows to manage the general settings
of the Kea DHCP server. The code can be found in
'plugins/modules/dhcp_general.py' and
'plugins/module_utils/dhcp_general.py'
@ansibleguy
Copy link
Owner

Alright - I've done some work on the module.

Please always:

Would you mind adding the docs?

@ansibleguy ansibleguy marked this pull request as ready for review January 11, 2025 18:39
@woelfle
Copy link
Author

woelfle commented Jan 24, 2025

Alright - I've done some work on the module.

Please always:

* Add tests for new modules or module-functionality

* Add documentation: https://github.com/ansibleguy/collection_opnsense/blob/latest/docs/source/modules/dhcp.rst

Would you mind adding the docs?

I'll add the docs. I'll also try to read a bit into the test code so I am able to provide tests in upcoming PRs. Thanks again for reviewing.

@jkhsjdhjs
Copy link

I just tried to use this module with OPNSense 24.7, but it doesn't seem to be compatible although 24.7 is the latest release (if you exclude 25.1, which was released yesterday). If I interpret the error message correctly, our OPNSense API doesn't seem to return the socket_type field this module expects. Do you have any idea as to what might be the issue? Thanks for your work on this!

ansible.errors.AnsibleModuleError: THIS MIGHT BE A MODULE-BUG: Failed to translate API entry to Ansible entry! Maybe the API changed lately?
Failed field: 'socket_type' | API entry: '{'enabled': '1', 'interfaces': {'lan': {'value': 'LAN', 'selected': 1}, 'opt1002': {'value': 'OPT1002', 'selected': 1}, 'opt1001': {'value': 'Room001', 'selected': 1}, 'opt1003': {'value': 'Room003', 'selected': 0}, [...shortened it a bit...], 'wan': {'value': 'WAN', 'selected': 0}}, 'valid_lifetime': '4000', 'fwrules': '1'}' '{'lifetime': 4000, 'fw_rules': True, 'enabled': True, 'interfaces': ['lan', 'opt1001', 'opt1002']}'\n", "module_stdout": "", "msg": "MODULE FAILURE: No start of json char found\nSee stdout/stderr for the exact error", "rc": 1}

@ansibleguy ansibleguy added the enhancement New feature or request label Feb 7, 2025
@ansibleguy ansibleguy self-assigned this Feb 7, 2025
@ansibleguy ansibleguy merged commit 73ef9c0 into ansibleguy:latest Feb 7, 2025
2 checks passed
@jkhsjdhjs
Copy link

@ansibleguy Does this work now?

@ansibleguy
Copy link
Owner

@jkhsjdhjs I was not able to reproduce the issue.
At least the tests worked on 24.7 and also now on 25.1: https://github.com/ansibleguy/collection_opnsense/blob/latest/tests/dhcp_general.yml

Do you mind opening a separate issue and also provide the specific Ansible-Task & -Config that does not work?
https://github.com/ansibleguy/collection_opnsense/issues/new?template=problem.yml

@jkhsjdhjs
Copy link

@ansibleguy Hmm, alright, I will test it again with the merged version in the next days and report back!

@jkhsjdhjs
Copy link

Got it to work by updating to a more recent 24.7 release or 25.1. Seems like my OPNSense version didn't have the socket_type option yet, that's why it failed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants