Skip to content

Add KEA DHCP provider feature for foreman-proxy#531

Open
archanaserver wants to merge 6 commits into
theforeman:masterfrom
archanaserver:dhcp-kea-external
Open

Add KEA DHCP provider feature for foreman-proxy#531
archanaserver wants to merge 6 commits into
theforeman:masterfrom
archanaserver:dhcp-kea-external

Conversation

@archanaserver

@archanaserver archanaserver commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

Why are you introducing these changes? (Problem description, related links)

ISC DHCP reached end-of-life in October 2022 and has been removed from RHEL 10. This adds support for KEA DHCP as the replacement.

What are the changes introduced in this pull request?

  • Add dhcp-kea-external feature definition to src/features.yaml
  • Create Smart Proxy configuration template dhcp_kea_api.yml.j2
  • Add default Ansible variables for KEA server connection (localhost:8000, default subnet)
  • Add integration tests for DHCP KEA feature validation

How to test this pull request

Steps to reproduce:

  1. Verify feature is available: ./foremanctl features | grep dhcp-kea-external
  2. Deploy with KEA DHCP feature enabled: ./foremanctl deploy --add-feature dhcp-kea-external
  3. Verify feature is enabled: ./foremanctl features --list-enabled | grep dhcp-kea-external
  4. Check configuration file was created: podman exec foreman-proxy ls -la /etc/foreman-proxy/settings.d/dhcp_kea_api.yml
  5. Run tests python -m pytest tests/foreman_proxy_test.py::test_dhcp_kea_feature_present -v

Checklist

  • Tests added/updated (if applicable)
  • Documentation updated (if applicable)

Comment thread src/features.yaml Outdated
description: Power management for bare metal hosts (IPMI, Redfish)
foreman_proxy:
plugin_name: bmc
dhcp-kea-external:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the feature should be "dhcp" and then you add a parameter to select which provider to use, with kea being one of the answers

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes way more sense to have a single dhcp feature with a provider parameter

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I played with that thought in #532 for the DNS side of things, would love to hear your opinion on the approach I took

foreman_proxy_bmc_redfish_verify_ssl: true

# KEA DHCP settings (external unmanaged server)
foreman_proxy_dhcp_kea_server: localhost

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are the chances that localhost is a place where a Kea will actually run (outside of development setups)?

I think we should leave that undef (like in https://github.com/theforeman/foremanctl/pull/523/changes) and force the user to set a sensible value.


:enabled: {{ feature_enabled }}
:use_provider: dhcp_kea_api
:server: {{ foreman_proxy_dhcp_kea_server }}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where does this come from? I don't see such an option in https://gitlab.surrey.ac.uk/sm0049/smart-proxy-dhcp-kea-api/

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, i was just playing around with few things, needed to look again, the reason i added that in draft but thanks for reviews, also i tryna fix few things with the updated changes.

:enabled: {{ feature_enabled }}
:use_provider: dhcp_kea_api
:server: {{ foreman_proxy_dhcp_kea_server }}
:kea_url: {{ foreman_proxy_dhcp_kea_url }}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this be kea_api_url?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also, we need kea_api_username and kea_api_password

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes def

:use_provider: dhcp_kea_api
:server: {{ foreman_proxy_dhcp_kea_server }}
:kea_url: {{ foreman_proxy_dhcp_kea_url }}
:kea_subnet: {{ foreman_proxy_dhcp_kea_subnet }}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where does this come from? I don't see such an option in https://gitlab.surrey.ac.uk/sm0049/smart-proxy-dhcp-kea-api/

@evgeni

evgeni commented Jun 1, 2026

Copy link
Copy Markdown
Member

Shall we package https://gitlab.surrey.ac.uk/sm0049/smart-proxy-dhcp-kea-api until we figure out whether we want to merge it into core or not?

@archanaserver

archanaserver commented Jun 2, 2026

Copy link
Copy Markdown
Contributor Author

Shall we package https://gitlab.surrey.ac.uk/sm0049/smart-proxy-dhcp-kea-api until we figure out whether we want to merge it into core or not?

Yeah, I was thinking we can package it for now, that will be independent of our decision about potentially merging it into the core later.

foreman_proxy_bmc_redfish_verify_ssl: true

# DHCP settings
foreman_proxy_dhcp_provider: dhcp_kea_api

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just:

Suggested change
foreman_proxy_dhcp_provider: dhcp_kea_api
foreman_proxy_dhcp_provider: dhcp_kea

:kea_api_password: {{ foreman_proxy_dhcp_kea_api_password }}
{% endif %}
{% if foreman_proxy_dhcp_kea_managed_subnets is defined and foreman_proxy_dhcp_kea_managed_subnets %}
:managed_subnets:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

foreman_proxy_dhcp_kea_api_url: "{{ undef(hint='You must specify the KEA API URL') }}"
foreman_proxy_dhcp_kea_api_username: ""
foreman_proxy_dhcp_kea_api_password: ""
foreman_proxy_dhcp_kea_managed_subnets: []

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be:

Suggested change
foreman_proxy_dhcp_kea_managed_subnets: []
foreman_proxy_dhcp_subnets: []

as in https://github.com/theforeman/smart-proxy/blob/develop/config/settings.d/dhcp.yml.example

@evgeni

evgeni commented Jun 2, 2026

Copy link
Copy Markdown
Member

Shall we package https://gitlab.surrey.ac.uk/sm0049/smart-proxy-dhcp-kea-api until we figure out whether we want to merge it into core or not?

Yeah, I was thinking we can package it for now, that will be independent of our decision about potentially merging it into the core later.

Do you want to do it, or shall I?

Comment thread src/features.yaml
@archanaserver

Copy link
Copy Markdown
Contributor Author

Shall we package https://gitlab.surrey.ac.uk/sm0049/smart-proxy-dhcp-kea-api until we figure out whether we want to merge it into core or not?

Yeah, I was thinking we can package it for now, that will be independent of our decision about potentially merging it into the core later.

Do you want to do it, or shall I?

I'll do it

@archanaserver archanaserver marked this pull request as ready for review June 4, 2026 09:51
@archanaserver

Copy link
Copy Markdown
Contributor Author

Update: Following the refinement session, we decided to integrate the KEA DHCP provider directly into smart-proxy core rather than packaging it as an external gem. I'm on it. So keeping this into draft till then.

Also looking at the current CI test failures, I believe they are coming from IOP tests failures and are unrelated to the DHCP feature changes in this PR.

@archanaserver archanaserver marked this pull request as draft June 11, 2026 09:40
@archanaserver archanaserver force-pushed the dhcp-kea-external branch 2 times, most recently from 16f5653 to a4dd887 Compare June 15, 2026 10:47
type: Boolean
foreman_proxy_dhcp_kea_api_url:
parameter: --foreman-proxy-dhcp-kea-api-url
help: KEA Control Agent API URL (e.g., http://kea-server:8000/)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: https example

Suggested change
help: KEA Control Agent API URL (e.g., http://kea-server:8000/)
help: KEA Control Agent API URL (e.g., https://kea-server)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(foreman_proxy_dhcp_kea_verify_ssl) is true by default, so this should be https

help: KEA Control Agent API URL (e.g., http://kea-server:8000/)
foreman_proxy_dhcp_kea_api_username:
parameter: --foreman-proxy-dhcp-kea-api-username
help: Optional HTTP Basic Auth username for KEA API

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to make it optional? It's not really secure IMO

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have updated it but auth is genuinely optional for kea control agent (many deployments run without auth on internal networks), but i agree we should encourage it for security. so fixed it


# KEA DHCP provider settings (when foreman_proxy_dhcp_provider is dhcp_kea)
foreman_proxy_dhcp_kea_api_url: "{{ undef(hint='You must specify the KEA API URL') }}"
foreman_proxy_dhcp_kea_api_username: "{{ undef(hint='Optional HTTP Basic Auth username for KEA API') }}"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the parameter is optional, why raise an error when no value is provided?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I removed optional from the hint text to reduce any confusion but the undef() is never actually raised because the template checks if you see

{% if foreman_proxy_dhcp_kea_api_username is defined and foreman_proxy_dhcp_kea_api_username %}
:dhcp_kea_api_username: {{ foreman_proxy_dhcp_kea_api_username }}
{% else %}
:dhcp_kea_api_username: ~
{% endif %}

is defined before using it. I added just to satisfy the linter earlier. do you have any other suggestons?

help: Optional HTTP Basic Auth password for KEA API
foreman_proxy_dhcp_kea_verify_ssl:
parameter: --foreman-proxy-dhcp-kea-verify-ssl
help: Verify SSL certificates when connecting to KEA API

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mention the default value (true)

# KEA DHCP provider settings (when foreman_proxy_dhcp_provider is dhcp_kea)
foreman_proxy_dhcp_kea_api_url: "{{ undef(hint='You must specify the KEA API URL') }}"
foreman_proxy_dhcp_kea_api_username: "{{ undef(hint='Optional HTTP Basic Auth username for KEA API') }}"
foreman_proxy_dhcp_kea_api_password: "{{ undef(hint='Optional HTTP Basic Auth password for KEA API') }}"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

parameter: --bmc-redfish-verify-ssl
help: Verify SSL certificates for Redfish BMC connections.
type: Boolean
foreman_proxy_dhcp_kea_api_url:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see a parameter for DHCP subnets.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, now we can specify this

Comment thread src/features.yaml
Comment thread tests/foreman_proxy_test.py
archanaserver added a commit to archanaserver/smart-proxy that referenced this pull request Jun 16, 2026
Ref: theforeman/foremanctl#531 (comment)

ISC DHCP reached end-of-life in October 2022 and is no longer maintained.
ISC officially recommends migrating to KEA DHCP as the replacement.

This commit adds Smart Proxy DHCP provider for ISC KEA DHCP server using
the KEA Control Agent API, providing a migration path for users currently
using the deprecated dhcp_isc provider.

Based on the `smart_proxy_dhcp_kea_api` gem by Sam McCarthy
with author's permission to integrate into Smart Proxy core.
https://gitlab.surrey.ac.uk/sm0049/smart-proxy-dhcp-kea-api/-/issues/3

Fixes: https://redhat.atlassian.net/browse/SAT-27739
archanaserver added a commit to archanaserver/smart-proxy that referenced this pull request Jun 16, 2026
Ref: theforeman/foremanctl#531 (comment)

ISC DHCP reached end-of-life in October 2022 and is no longer maintained.
ISC officially recommends migrating to KEA DHCP as the replacement.

This commit adds Smart Proxy DHCP provider for ISC KEA DHCP server using
the KEA Control Agent API, providing a migration path for users currently
using the deprecated dhcp_isc provider.

Based on the `smart_proxy_dhcp_kea_api` gem by Sam McCarthy
with author's permission to integrate into Smart Proxy core.
https://gitlab.surrey.ac.uk/sm0049/smart-proxy-dhcp-kea-api/-/issues/3

Fixes: https://redhat.atlassian.net/browse/SAT-27739
Comment thread src/roles/foreman_proxy/defaults/main.yaml
:dhcp_kea_password: ~
{% endif %}
:dhcp_kea_verify_ssl: {{ foreman_proxy_dhcp_kea_verify_ssl | default(true) | lower }}
:dhcp_kea_lease_timeout: {{ foreman_proxy_dhcp_kea_lease_timeout | default(60) }}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default value should be set in the src/roles/foreman_proxy/defaults/main.yaml

:dhcp_kea_password: ~
{% endif %}
:dhcp_kea_verify_ssl: {{ foreman_proxy_dhcp_kea_verify_ssl | default(true) | lower }}
:dhcp_kea_lease_timeout: {{ foreman_proxy_dhcp_kea_lease_timeout | default(60) }}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: Do we want to give users a chance to edit this value via foremanctl? If yes, then we need another parameter for it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, both values are exposed as CLI parameters

{% else %}
:dhcp_kea_password: ~
{% endif %}
:dhcp_kea_verify_ssl: {{ foreman_proxy_dhcp_kea_verify_ssl | default(true) | lower }}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this needed when the default value is already set in src/roles/foreman_proxy/defaults/main.yaml?

Suggested change
:dhcp_kea_verify_ssl: {{ foreman_proxy_dhcp_kea_verify_ssl | default(true) | lower }}
:dhcp_kea_verify_ssl: {{ foreman_proxy_dhcp_kea_verify_ssl }}

Comment thread tests/foreman_proxy_test.py
archanaserver added a commit to archanaserver/smart-proxy that referenced this pull request Jun 22, 2026
Ref: theforeman/foremanctl#531 (comment)

ISC DHCP reached end-of-life in October 2022 and is no longer maintained.
ISC officially recommends migrating to KEA DHCP as the replacement.

This commit adds Smart Proxy DHCP provider for ISC KEA DHCP server using
the KEA Control Agent API, providing a migration path for users currently
using the deprecated dhcp_isc provider.

Based on the `smart_proxy_dhcp_kea_api` gem by Sam McCarthy
with author's permission to integrate into Smart Proxy core.
https://gitlab.surrey.ac.uk/sm0049/smart-proxy-dhcp-kea-api/-/issues/3

Fixes: https://redhat.atlassian.net/browse/SAT-27739

Fix Rubocop failures

Simplify KEA plugin config loading
archanaserver added a commit to archanaserver/smart-proxy that referenced this pull request Jun 22, 2026
Ref: theforeman/foremanctl#531 (comment)

ISC DHCP reached end-of-life in October 2022 and is no longer maintained.
ISC officially recommends migrating to KEA DHCP as the replacement.

This commit adds Smart Proxy DHCP provider for ISC KEA DHCP server using
the KEA Control Agent API, providing a migration path for users currently
using the deprecated dhcp_isc provider.

Based on the `smart_proxy_dhcp_kea_api` gem by Sam McCarthy
with author's permission to integrate into Smart Proxy core.
https://gitlab.surrey.ac.uk/sm0049/smart-proxy-dhcp-kea-api/-/issues/3

Fixes: https://redhat.atlassian.net/browse/SAT-27739

Fix Rubocop failures

Simplify KEA plugin config loading
archanaserver added a commit to archanaserver/smart-proxy that referenced this pull request Jun 22, 2026
Ref: theforeman/foremanctl#531 (comment)

ISC DHCP reached end-of-life in October 2022 and is no longer maintained.
ISC officially recommends migrating to KEA DHCP as the replacement.

This commit adds Smart Proxy DHCP provider for ISC KEA DHCP server using
the KEA Control Agent API, providing a migration path for users currently
using the deprecated dhcp_isc provider.

Based on the `smart_proxy_dhcp_kea_api` gem by Sam McCarthy
with author's permission to integrate into Smart Proxy core.
https://gitlab.surrey.ac.uk/sm0049/smart-proxy-dhcp-kea-api/-/issues/3

Fixes: https://redhat.atlassian.net/browse/SAT-27739

Fix Rubocop failures

Simplify KEA plugin config loading
archanaserver added a commit to archanaserver/smart-proxy that referenced this pull request Jun 22, 2026
Ref: theforeman/foremanctl#531 (comment)

ISC DHCP reached end-of-life in October 2022 and is no longer maintained.
ISC officially recommends migrating to KEA DHCP as the replacement.

This commit adds Smart Proxy DHCP provider for ISC KEA DHCP server using
the KEA Control Agent API, providing a migration path for users currently
using the deprecated dhcp_isc provider.

Based on the `smart_proxy_dhcp_kea_api` gem by Sam McCarthy
with author's permission to integrate into Smart Proxy core.
https://gitlab.surrey.ac.uk/sm0049/smart-proxy-dhcp-kea-api/-/issues/3

Fixes: https://redhat.atlassian.net/browse/SAT-27739

Fix Rubocop failures

Simplify KEA plugin config loading
@archanaserver archanaserver marked this pull request as ready for review June 23, 2026 06:27
@archanaserver archanaserver self-assigned this Jun 23, 2026
archanaserver added a commit to archanaserver/smart-proxy that referenced this pull request Jun 23, 2026
Ref: theforeman/foremanctl#531 (comment)

ISC DHCP reached end-of-life in October 2022 and is no longer maintained.
ISC officially recommends migrating to KEA DHCP as the replacement.

This commit adds Smart Proxy DHCP provider for ISC KEA DHCP server using
the KEA Control Agent API, providing a migration path for users currently
using the deprecated dhcp_isc provider.

Based on the `smart_proxy_dhcp_kea_api` gem by Sam McCarthy
with author's permission to integrate into Smart Proxy core.
https://gitlab.surrey.ac.uk/sm0049/smart-proxy-dhcp-kea-api/-/issues/3

Fixes: https://redhat.atlassian.net/browse/SAT-27739

Fix Rubocop failures

Simplify KEA plugin config loading
Comment thread development/playbooks/kea/kea.yaml Outdated
- name: Configure Kea DHCP4 server
ansible.builtin.copy:
dest: /etc/kea/kea-dhcp4.conf
content: |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make it a file/template?

name: kea-ctrl-agent
state: started

- name: Wait for Kea Control Agent to be ready

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is failing for me, repeatedly.

TASK [Wait for Kea Control Agent to be ready] ****************************************************************************************************
[ERROR]: Task failed: Module failed: Timeout when waiting for 127.0.0.1:8000
Origin: /home/lstejska/projects/foremanctl/development/playbooks/kea/kea.yaml:115:7

113         state: started
114
115     - name: Wait for Kea Control Agent to be ready
          ^ column 7

fatal: [quadlet]: FAILED! => {
    "changed": false,
    "elapsed": 30
}

MSG:

Timeout when waiting for 127.0.0.1:8000

PLAY RECAP ***************************************************************************************************************************************
quadlet                    : ok=12   changed=9    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0

before I ran:

./foremanctl deploy --initial-admin-password=changeme --tuning development --add-feature foreman-proxy --add-feature dhcp --foreman-proxy-dhcp-kea-url http://127.0.0.1:8000

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see it for me as well, taking a look on it

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also you don't need to include --add-feature foreman-proxy, I have added it as a dependency in the dhcp with expand_features that automatically includes all dependencies.

Comment thread .github/workflows/test.yml Outdated
- name: Create installer certificates
if: contains(matrix.certificate_source, 'installer')
run: |
./forge installer-certs

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this needed?

For me it's failing with:

forge: error: argument action: invalid choice: 'installer-certs' (choose from 'custom-certs', 'deploy-dev', 'kea', 'lock', 'mock-installer', 'remote-database', 'security', 'setup-repositories', 'smoker', 'sos', 'test', 'vms'

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see that's a leftover dead code. I should have dropped earlier. Let's see now

Adds the dhcp-kea-external feature to enable Smart Proxy integration
with external KEA DHCP servers.
Since it defaults to dhcp_kea, we don't need to pass it at all
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants