From 74b479427ddd482a879c751735e102d4be39c5e8 Mon Sep 17 00:00:00 2001 From: Shubham Ganar Date: Mon, 25 May 2026 22:42:34 +0530 Subject: [PATCH 1/2] Add Templates feature to foreman-proxy Signed-off-by: Shubham Ganar --- .github/workflows/test.yml | 3 +++ docs/user/parameters.md | 5 +++-- src/features.yaml | 4 ++++ src/playbooks/_foreman_proxy/metadata.obsah.yaml | 10 ++++++++++ .../templates/settings.d/templates.yml.j2 | 4 ++++ src/vars/flavors/foreman-proxy-content.yml | 1 + tests/feature/foreman-proxy/base_test.py | 11 +++++++++++ 7 files changed, 36 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 a4de220da..4003bd0a0 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -153,6 +153,9 @@ jobs: --add-feature remote-execution \ --add-feature bmc \ --add-feature webhooks \ + --add-feature templates \ + --templates-listen-on http \ + --templates-url http://quadlet.example.com:8000 \ ${{ matrix.iop == 'enabled' && '--add-feature iop' || '' }} - name: Run tests run: | diff --git a/docs/user/parameters.md b/docs/user/parameters.md index cb9ca5dab..865a0019f 100644 --- a/docs/user/parameters.md +++ b/docs/user/parameters.md @@ -128,6 +128,9 @@ There are multiple use cases from the users perspective that dictate what parame | `--add-feature content/ostree` | Enable OSTree content type | `--foreman-proxy-content-enable-ostree` | | `--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` | +| `--templates-url` | URL that hosts will use to contact the proxy for provisioning templates | `--foreman-proxy-templates-url` | ### Undetermined @@ -200,8 +203,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 88d21c832..82a38fd14 100644 --- a/src/features.yaml +++ b/src/features.yaml @@ -71,3 +71,7 @@ webhooks: foreman: plugin_name: foreman_webhooks hammer: foreman_webhooks +templates: + description: Templates feature for foreman-proxy + foreman_proxy: + plugin_name: templates diff --git a/src/playbooks/_foreman_proxy/metadata.obsah.yaml b/src/playbooks/_foreman_proxy/metadata.obsah.yaml index c0d3da1c2..7fedc8259 100644 --- a/src/playbooks/_foreman_proxy/metadata.obsah.yaml +++ b/src/playbooks/_foreman_proxy/metadata.obsah.yaml @@ -10,3 +10,13 @@ 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_templates_url: + parameter: --templates-url + help: URL that hosts will use to contact the proxy for provisioning templates (e.g. http://:8000). Required when templates feature is enabled. 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..e3cabd472 --- /dev/null +++ b/src/roles/foreman_proxy/templates/settings.d/templates.yml.j2 @@ -0,0 +1,4 @@ +--- +:enabled: {% if foreman_proxy_templates_listen_on | default('both') == 'both' %}true{% else %}{{ foreman_proxy_templates_listen_on }}{% endif %} + +:template_url: {{ foreman_proxy_templates_url }} diff --git a/src/vars/flavors/foreman-proxy-content.yml b/src/vars/flavors/foreman-proxy-content.yml index 833b22678..d91adb384 100644 --- a/src/vars/flavors/foreman-proxy-content.yml +++ b/src/vars/flavors/foreman-proxy-content.yml @@ -5,6 +5,7 @@ flavor_features: - content/container - content/ansible - content/python + - templates pulp_mirror: true pulp_rhsm_url: "https://{{ ansible_facts['fqdn'] }}/rhsm" diff --git a/tests/feature/foreman-proxy/base_test.py b/tests/feature/foreman-proxy/base_test.py index 1189074d0..656e4251b 100644 --- a/tests/feature/foreman-proxy/base_test.py +++ b/tests/feature/foreman-proxy/base_test.py @@ -27,6 +27,10 @@ def test_foreman_proxy_features(curl_request, proxy_base_url, enabled_features): 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): @@ -65,3 +69,10 @@ 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_template_url(proxy_v2_features): + settings = proxy_v2_features['templates'].get('settings', {}) + template_url = settings.get('template_url') + assert template_url == 'http://quadlet.example.com:8000' From 7eb0af0d5e959884df0929abff4db45cdd9ab809 Mon Sep 17 00:00:00 2001 From: Shubham Ganar Date: Wed, 22 Jul 2026 22:20:20 +0530 Subject: [PATCH 2/2] Fix templates deploy on content proxy by setting templates-url Signed-off-by: Shubham Ganar --- .github/workflows/test.yml | 7 +++---- src/roles/foreman_proxy/defaults/main.yaml | 3 +++ tests/feature/foreman-proxy/base_test.py | 7 +++---- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4003bd0a0..29bbd0ab3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -153,9 +153,6 @@ jobs: --add-feature remote-execution \ --add-feature bmc \ --add-feature webhooks \ - --add-feature templates \ - --templates-listen-on http \ - --templates-url http://quadlet.example.com:8000 \ ${{ matrix.iop == 'enabled' && '--add-feature iop' || '' }} - name: Run tests run: | @@ -446,7 +443,9 @@ jobs: --certificate-bundle $(pwd)/.var/lib/foremanctl/proxy.example.com.tar.gz \ --foreman-fqdn quadlet.example.com \ --oauth-consumer-key $(cat .var/lib/foremanctl/foreman-oauth-consumer-key) \ - --oauth-consumer-secret $(cat .var/lib/foremanctl/foreman-oauth-consumer-secret) + --oauth-consumer-secret $(cat .var/lib/foremanctl/foreman-oauth-consumer-secret) \ + --templates-listen-on http \ + --templates-url http://proxy.example.com:8000 - name: Run tests run: | ./forge test --pytest-args="--server-hostname=proxy" diff --git a/src/roles/foreman_proxy/defaults/main.yaml b/src/roles/foreman_proxy/defaults/main.yaml index abd664b17..cd4200fd9 100644 --- a/src/roles/foreman_proxy/defaults/main.yaml +++ b/src/roles/foreman_proxy/defaults/main.yaml @@ -18,6 +18,9 @@ foreman_proxy_disabled_features: "{{ foreman_proxy_available_features | differen foreman_proxy_foreman_server_url: "https://{{ ansible_facts['fqdn'] }}" +# Templates settings +foreman_proxy_templates_url: "http://{{ foreman_proxy_name }}:8000" + # BMC settings foreman_proxy_bmc_ipmi_implementation: ipmitool foreman_proxy_bmc_redfish_verify_ssl: true diff --git a/tests/feature/foreman-proxy/base_test.py b/tests/feature/foreman-proxy/base_test.py index 656e4251b..a4251b652 100644 --- a/tests/feature/foreman-proxy/base_test.py +++ b/tests/feature/foreman-proxy/base_test.py @@ -72,7 +72,6 @@ def test_bmc_default_provider(proxy_v2_features): @pytest.mark.feature('templates') -def test_templates_template_url(proxy_v2_features): - settings = proxy_v2_features['templates'].get('settings', {}) - template_url = settings.get('template_url') - assert template_url == 'http://quadlet.example.com:8000' +def test_templates_template_url(obsah_params, server_fqdn): + template_url = obsah_params.get('foreman_proxy_templates_url') + assert template_url == f'http://{server_fqdn}:8000'