Skip to content

Add Templates feature to foreman-proxy#519

Open
shubhamsg199 wants to merge 1 commit into
theforeman:masterfrom
shubhamsg199:templates-feature
Open

Add Templates feature to foreman-proxy#519
shubhamsg199 wants to merge 1 commit into
theforeman:masterfrom
shubhamsg199:templates-feature

Conversation

@shubhamsg199

Copy link
Copy Markdown
Contributor

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

What are the changes introduced in this pull request?

  • Enable templates feature for foreman-proxy

How to test this pull request

Steps to reproduce:

  • foremanctl deploy --add-feature templates

Checklist

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

@shubhamsg199 shubhamsg199 self-assigned this May 25, 2026
@shubhamsg199 shubhamsg199 marked this pull request as draft May 25, 2026 17:31
Comment thread src/playbooks/deploy/metadata.obsah.yaml
@shubhamsg199 shubhamsg199 marked this pull request as ready for review June 3, 2026 09:30
@shubhamsg199 shubhamsg199 force-pushed the templates-feature branch 3 times, most recently from 77b2cc9 to 6be7b5b Compare June 5, 2026 15:23
Comment thread .github/workflows/test.yml
@ehelms

ehelms commented Jun 10, 2026

Copy link
Copy Markdown
Member

Does templates need to be in the features.yaml? I do not see how the feature in this PR ensures foreman-proxy gets added.

@shubhamsg199

shubhamsg199 commented Jun 11, 2026

Copy link
Copy Markdown
Contributor Author

Does templates need to be in the features.yaml? I do not see how the feature in this PR ensures foreman-proxy gets added.

Yes, templates is declared in features.yaml under the foreman_proxy key (same pattern as bmc). I don't think we have a way to ensure if foreman-proxy gets added.

@shubhamsg199 shubhamsg199 force-pushed the templates-feature branch 4 times, most recently from 713b3d9 to ded1e9b Compare June 11, 2026 17:00
@shubhamsg199

shubhamsg199 commented Jun 11, 2026

Copy link
Copy Markdown
Contributor Author

@ehelms Made some updates that ensures foreman-proxy gets added on the feature install. Not sure if that should be part of this PR.

Comment thread tests/foreman_proxy_test.py Outdated
@shubhamsg199 shubhamsg199 force-pushed the templates-feature branch 2 times, most recently from f0ba618 to b20b505 Compare June 12, 2026 15:23
Comment thread src/filter_plugins/foremanctl.py
Signed-off-by: Shubham Ganar <shubhamsg123m@gmail.com>
@@ -0,0 +1,3 @@
---
:enabled: {{ feature_enabled }}

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.

as you're exposing "listen on", you'd need to alter the value of :enabled: accordingly. (both maps to true, the others can be used directly to only enable http/https mode.

so far we have not been opening the http port at all, and all plugins are configured for both/true.

given templates is the first one that is actually useful over plain http, we need to rethink that now

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.

What's the point of setting it to http or https? Why not just true / false?
Do we enforce SSL when the value is https or true?

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.

We don't enforce SSL in that case, no.

But if a module is enabled on plain HTTP, the authorization is reduced to "the reverse DNS matches an entry in trusted_hosts" aka "no authorization as everyone can fake this shit"¹.

So we need to only ever allow plain HTTP to modules that don't need authorization (like templates).

¹: This is not a problem today, as we don't expose the HTTP port at all

Comment thread .github/workflows/test.yml
settings = proxy_v2_features['templates'].get('settings', {})
template_url = settings.get('template_url')
assert template_url == 'http://quadlet.example.com:8000'

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.

can we write a test that actually uses the template feature to get data?

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.

+1

Comment thread docs/user/parameters.md
| `--add-feature bmc` | Enable BMC feature | `--foreman-proxy-bmc` |
| `--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` |

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.

@@ -0,0 +1,3 @@
---
:enabled: {{ feature_enabled }}

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.

What's the point of setting it to http or https? Why not just true / false?
Do we enforce SSL when the value is https or true?

@@ -0,0 +1,3 @@
---
:enabled: {{ feature_enabled }}
:template_url: {{ foreman_proxy_templates_url | default('http://' + ansible_facts['fqdn'] + ':8000') }} No newline at end of file

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: What if we did not provide a default value and instead required users to set it manually?

Plus, you need two default values: one for HTTP and one for HTTPS.

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.

No newline at end of file

That should be fixed as well.

settings = proxy_v2_features['templates'].get('settings', {})
template_url = settings.get('template_url')
assert template_url == 'http://quadlet.example.com: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.

+1

--add-feature remote-execution \
--add-feature bmc \
--add-feature templates \
--templates-listen-on http \

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.

What if we drop it? Is this parameter still relevant?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants