-
Notifications
You must be signed in to change notification settings - Fork 1.7k
kea_command: new module to access an ISC KEA server
#10709
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
Conversation
Huh.
|
|
Thanks for your contribution!
The sanity test was removed from ansible-core 2.17 I think (since 2.17 dropped support for Python 2.7 on the target as well), but this collection still supports ansible-core 2.16, whose sanity tests still require it, and which also still supports Python 2.7 on the target. (We'll remove support for ansible-core 2.16 in the next major release in ~November this year. From then on it's no longer needed.) |
|
Felix Fontein dixit:
this collection still supports ansible-core 2.16, whose sanity tests
still require it, and which also still supports Python 2.7 on the
target.
Ah, okay. I will try to port this thing to Python then, although
the service it accesses is recent enough it’s normally available
only on distros that ship only py3k.
It’s a bit tricky as I seem to have to rely on the CI, as the
sanity tests from the documentation pass when I run them locally.
|
You can install ansible-core 2.16 locally and use its ansible-test, but note that it will refuse to run if you don't run it with Python 3.10, 3.11, or 3.12... In any case, usually running sanity tests with the latest (or one of the latest) ansible-core release is perfectly fine, this only changed once ansible-core 2.17 dropped support for Python 2.7, and is only a problem while we still support ansible-core versions that still support Python 2.7. Which fortunately ends (at least for (And yes, I've been looking forward to this for years :D ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution!
|
On Sat, 23 Aug 2025, Felix Fontein wrote:
Hmm, the image works fine for me without privileged mode (and I would
Does the integration test work for you without it?
|
No, I could imagine that it would work fine in some of the test VMs though that are used in CI (various versions of RHEL, Alpine 3.22, Ubuntu 22.04 and 24.04). |
|
24.04 is rather old for this (KEA is, while not brand new, only used by people now that ISC DHCP is EOL, and has had several major changes recently), but if you think it worth, I can try making a regression test for it. Rest ok then? |
|
Or, hm, well, if the “Networking setup, interface” step is the one that fails for you, then I don’t think it will even work there, I need an extra dummy network interface it can temporarily play DHCP server on for this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hi @mirabilos Thanks for your contribution!!!!
I got some comments myself, please take a look. Not everything is mandatory, feel free to disagree :-)
|
@mirabilos This PR contains |
That fails for me because it's in a container. Ubuntu 24.04 also runs as a VM, there this is not a problem. There are packages for KEA for Ubuntu 24.04, Alpine 3.22, and RHEL 10, all which are available as VMs in our CI. You should adjust the tests so they at least run with (at least) one of these VMs. |
Hm, okay. If it runs as VM, I can likely set up the service. I can try to get it working under Ubuntu noble. What magic incantations do I need in the tests/ subdirectory to make it select precisely that VM, and nothing else, to run the integration test? |
|
Basically add this to The TODOs are so that at some point hopefully someone extends the tests to also run on these systems. |
|
@felixfontein seems to pass CI now, with the test actually run on 24.04 VM. Before I’ll push without the debugging extra steps, is there anything else I need to change before this can be merged? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just some adjustments to the current repo state, I think then it's ok to merge.
4e5e1d7 to
cc1fa21
Compare
|
I’ve added a missing quote, more comments, and also a task to show the dhcp6 server log, for symmetry. |
cc1fa21 to
b7c2777
Compare
|
… and that ruff thing. |
b7c2777 to
54a4f1c
Compare
54a4f1c to
3bab065
Compare
|
On Sun, 2 Nov 2025, Felix Fontein wrote:
This is not compatible with how the collection adds new test targets.
How? It’s just a warning.
Please remove it.
Removed, as requested.
|
|
Thanks for removing it.
When we add a new platform to CI, we try running all existing tests against them (which don't already skip the category of platform, for example because they contain |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If nobody objects, I'll merge this later today/tomorrow.
|
On Sun, 2 Nov 2025, Felix Fontein wrote:
> How? It’s just a warning.
When we add a new platform to CI, we try running all existing tests
against them (which don't already skip the category of platform, for
example because they contain `skip/docker` or `skip/freebsd`). If
everything passes, the platform is just added. If not, specific tests
that don't pass are either adjusted (if it's simple enough) or
explicitly disabled (if it needs more work) and marked with a TODO.
Having to also take care of a warning for a new platform for a specific
test is just more work for maintainers when adding new platforms.
Ah! Okay, makes sense, thanks for the feedback.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @mirabilos
Couple of comments more.
| # Copyright © Felix Fontein <[email protected]> | ||
| # GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) | ||
|
|
||
| skip/python2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This module is to be added to c.g. 12.0.0, that no longer supports Python 2 (finally! 😄), so this line is now redundant.
| # better safe in case anything fails… | ||
| r["changed"] = True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the statement in line 165 below fails to send the command, then the module returns changed=true but nothing happened.
|
On Sun, 2 Nov 2025, Alexei Znamensky wrote:
+skip/python2
This module is to be added to c.g. 12.0.0, that no longer supports
Python 2 (finally! 😄), so this line is now redundant.
Phew. OK, will remove it.
> + # better safe in case anything fails…
+ r["changed"] = True
If the statement in line 165 below fails to send the command, then the
module returns `changed=true` but nothing happened.
That’s correct, I inserted this so that, for all cases where we
cannot *guarantee* that nothing changed, it reports changed
(plus an error), so that is from the possibly first byte sent.
|
Users (writing Ansible playbooks) should, of course, handle module failures (or they will pop up in their faces anyway), in which case I would say it is probably better not to return Hope that makes sense |
|
On Sun, 2 Nov 2025, Alexei Znamensky wrote:
in case of failure, the state of the service managed by kea is
undetermined and the user is responsible for checking it again before
making new moves.
isn’t that already implicit anyway? The setting means changed,
not succeeded to change to the desired state, after all ;)
|
|
In my gut I still feel this is kinda "wrong" but I cannot find a good objective argument to support that claim. Therefore, I rest my case. |
|
Most modules do not return In any case, I guess it doesn't hurt to try to return |
|
One would argue that using one name to mean something other than the wordvs semantics is a good way to get oneself into trouble. Been there, done that. But anyways, as I wrote before I lack a compelling argument here, so let's go :-) |
|
Thanks. I did point this out in the documentation, for what it’s worth:
|
This module can be used to access the JSON API of a KEA DHCP4, DHCP6, DDNS or other services in a generic way, without having to manually format the JSON, with response error code checking. It directly accesses the Unix Domain Socket API so it needs to execute on the system the server is running, with superuser privilegues, but without the hassle of wrapping it into HTTPS and password auth (or client certificates). The integration test uses a predefined setup for convenience, which runs on Debian trixie as well as, on the CI, Ubuntu noble. It makes assumptions about the default package configuration and paths and is therefore tricky to run on other distros/OSes. This only affects running the KEA server as part of the tests, not the module.
3bab065 to
59d58a7
Compare
|
@mirabilos thanks for your contribution! |
Please be gentle, this is my first Ansible module, but do tell me how to improve it to meet the same standards as other modules ;)
SUMMARY
This module can be used to access the JSON API of a KEA DHCP4, DHCP6, DDNS or other services in a generic way, without having to manually format the JSON, with response error code checking.
It directly accesses the Unix Domain Socket API so it needs to execute on the system the server is running, with superuser privilegues, but without the hassle of wrapping it into HTTPS and password auth (or client certificates).
ISSUE TYPE
COMPONENT NAME
kea_commandADDITIONAL INFORMATION
The integration test uses a predefined setup for convenience (i.e. so I can rely on a system setup I know and have tested); this in no way limits the usability of the module itself, it merely makes it easier to configure the “server component” of the integration test.