From 9a7993c27ac969e1b5c0579296d14c832d40db49 Mon Sep 17 00:00:00 2001 From: Shubham Ganar Date: Mon, 25 May 2026 22:42:34 +0530 Subject: [PATCH] Add Templates feature to foreman-proxy Signed-off-by: Shubham Ganar --- .github/workflows/test.yml | 1 + docs/user/parameters.md | 5 +++-- src/features.yaml | 4 ++++ src/playbooks/deploy/metadata.obsah.yaml | 10 ++++++++++ .../templates/settings.d/templates.yml.j2 | 3 +++ tests/foreman_proxy_test.py | 17 +++++++++++++++++ 6 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 src/roles/foreman_proxy/templates/settings.d/templates.yml.j2 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 00c24920b..45b92c082 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -159,6 +159,7 @@ jobs: --add-feature google \ --add-feature remote-execution \ --add-feature bmc \ + --add-feature templates \ ${{ matrix.iop == 'enabled' && '--add-feature iop' || '' }} - name: Run tests run: | diff --git a/docs/user/parameters.md b/docs/user/parameters.md index 5f167ff5a..697ecfb4d 100644 --- a/docs/user/parameters.md +++ b/docs/user/parameters.md @@ -111,6 +111,9 @@ There are multiple use cases from the users perspective that dictate what parame | --------- | ----------- | ---------------------------- | | `--bmc-ipmi-implementation` | IPMI implementation to use for BMC | `--foreman-proxy-bmc-default-provider` | | `--bmc-redfish-verify-ssl` | Verify SSL certificates for Redfish BMC connections | `--foreman-proxy-bmc-redfish-verify-ssl` | +| `--add-feature templates` | Enable Templates feature on Smart Proxy | `--foreman-proxy-templates` | +| `--templates-listen-on` | Templates proxy to listen on https, http, or both | `--foreman-proxy-templates-listen-on` | +| `--template-url` | URL that hosts will use to contact the proxy for provisioning templates | `--foreman-proxy-template-url` | ### Undetermined @@ -185,8 +188,6 @@ There are multiple use cases from the users perspective that dictate what parame | `--foreman-proxy-realm-provider` | | | | | `--foreman-proxy-registration` | | | | | `--foreman-proxy-registration-url` | | | | -| `--foreman-proxy-templates` | | | | -| `--foreman-proxy-template-url` | | | | | `--puppet-server` | | puppet | server | | `--puppet-server-ca` | | puppet | server_ca | | `--puppet-dns-alt-names` | | puppet | dns_alt_names | diff --git a/src/features.yaml b/src/features.yaml index f8284b019..198ed8aa3 100644 --- a/src/features.yaml +++ b/src/features.yaml @@ -48,3 +48,7 @@ bmc: description: Power management for bare metal hosts (IPMI, Redfish) foreman_proxy: plugin_name: bmc +templates: + description: Templates feature for foreman-proxy + foreman_proxy: + plugin_name: templates diff --git a/src/playbooks/deploy/metadata.obsah.yaml b/src/playbooks/deploy/metadata.obsah.yaml index c1a32b484..a494e9b61 100644 --- a/src/playbooks/deploy/metadata.obsah.yaml +++ b/src/playbooks/deploy/metadata.obsah.yaml @@ -56,6 +56,16 @@ variables: parameter: --bmc-redfish-verify-ssl help: Verify SSL certificates for Redfish BMC connections. type: Boolean + foreman_proxy_templates_listen_on: + parameter: --templates-listen-on + help: Templates proxy to listen on https, http, or both. + choices: + - http + - https + - both + foreman_proxy_template_url: + parameter: --template-url + help: URL that hosts will use to contact the proxy for provisioning templates. Defaults to http://:8000. constraints: required_together: diff --git a/src/roles/foreman_proxy/templates/settings.d/templates.yml.j2 b/src/roles/foreman_proxy/templates/settings.d/templates.yml.j2 new file mode 100644 index 000000000..95a59ed9b --- /dev/null +++ b/src/roles/foreman_proxy/templates/settings.d/templates.yml.j2 @@ -0,0 +1,3 @@ +--- +:enabled: {{ feature_enabled }} +:template_url: {{ foreman_proxy_template_url | default('http://' + ansible_facts['fqdn'] + ':8000') }} diff --git a/tests/foreman_proxy_test.py b/tests/foreman_proxy_test.py index 71ad8cbc0..3916e17d0 100644 --- a/tests/foreman_proxy_test.py +++ b/tests/foreman_proxy_test.py @@ -29,6 +29,10 @@ def test_foreman_proxy_features(server, certificates, server_fqdn, enabled_featu assert "bmc" in features else: assert "bmc" not in features + if 'templates' in enabled_features: + assert "templates" in features + else: + assert "templates" not in features def test_foreman_proxy_service(server): @@ -69,3 +73,16 @@ def test_bmc_capabilities(proxy_v2_features): def test_bmc_default_provider(proxy_v2_features): settings = proxy_v2_features['bmc'].get('settings', {}) assert settings.get('bmc_default_provider') == 'ipmitool' + + +@pytest.mark.feature('templates') +def test_templates_feature_enabled(proxy_v2_features): + assert 'templates' in proxy_v2_features + + +@pytest.mark.feature('templates') +def test_templates_template_url(proxy_v2_features, server_fqdn): + settings = proxy_v2_features['templates'].get('settings', {}) + template_url = settings.get('template_url') + assert template_url == f'http://{server_fqdn}:8000' +