Skip to content

prepare proxy before deployment#644

Draft
arvind4501 wants to merge 1 commit into
theforeman:masterfrom
arvind4501:prepare-proxy
Draft

prepare proxy before deployment#644
arvind4501 wants to merge 1 commit into
theforeman:masterfrom
arvind4501:prepare-proxy

Conversation

@arvind4501

Copy link
Copy Markdown
Contributor

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

Deploying a smart proxy requires a certificate bundle and OAuth credentials that live on the Foreman server. Previously there was no dedicated step to transfer these to the proxy host before running deploy-proxy, leaving users to handle that manually.

What are the changes introduced in this pull request?

  • Add foremanctl prepare-proxy command — validates that a certificate bundle exists on the Foreman server, then copies it along with the OAuth consumer key and secret to the proxy host over SSH
  • Add src/playbooks/prepare-proxy/prepare-proxy.yaml — two-play playbook: first play runs on the Foreman host to validate and fetch the certificate bundle; second play connects to the proxy over SSH to transfer the bundle and OAuth credentials
  • Add src/playbooks/prepare-proxy/metadata.obsah.yaml — exposes the command via obsah with a required --hostname parameter
  • Move OAuth credential reading into src/roles/pre_install/tasks/foreman-proxy-content.yaml and include it conditionally for the foreman-proxy-content flavor

How to test this pull request

Steps to reproduce:

  • Deploy a Foreman server with foremanctl deploy
  • Generate a certificate bundle for the proxy: foremanctl certificate-bundle
  • Ensure SSH key-based access from the Foreman server to the proxy host is configured
  • Run foremanctl prepare-proxy and verify it completes without errors
  • Run foremanctl deploy-proxy --flavor foreman-proxy-content --certificate-bundle /root/proxy.example.com.tar.gz --foreman-fqdn quadlet.example.com and verify the OAuth credentials are picked up correctly from the transferred files

Checklist

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

@arvind4501
arvind4501 marked this pull request as draft July 10, 2026 10:38
@arvind4501

Copy link
Copy Markdown
Contributor Author

The prerequisites for prepare-proxy is , user can do key based ssh to proxy server from foreman server

@evgeni

evgeni commented Jul 10, 2026

Copy link
Copy Markdown
Member

What's the envisioned user workflow here, given that the current way of storing parameters limits us pretty hard on having "single foremanctl install manages multiple servers and proxies" working?

Something like:

  • on server: foremanctl deploy
  • on server: foremanctl certificate-bundle proxy.example.com
  • on server: foremanctl prepare-proxy --target proxy.example.com
  • on proxy: foremanctl deploy-proxy …

@arvind4501

Copy link
Copy Markdown
Contributor Author

What's the envisioned user workflow here, given that the current way of storing parameters limits us pretty hard on having "single foremanctl install manages multiple servers and proxies" working?

Something like:

  • on server: foremanctl deploy
  • on server: foremanctl certificate-bundle proxy.example.com
  • on server: foremanctl prepare-proxy --target proxy.example.com
  • on proxy: foremanctl deploy-proxy …

yes, the goal was to get rid of manually copying certificate bundle and passing oauth creds with deploy-proxy

- name: Check SSH connectivity and authentication to proxy
ansible.builtin.ping:

- name: Copy certificate bundle to proxy

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.

this particular step does behave differently for dev and prod setup, idea was to copy the bundle to proxy machine, but that contradicts with dev workflow where we fetch bundle locally on controller and use 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.

on dev and CI , fetching bundle would work but in production we need to copy bundle over to proxy machine

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.

Try not to think of this as "dev" and "prod". Instead, think of this as control node and target node. See #630

@arvind4501
arvind4501 force-pushed the prepare-proxy branch 2 times, most recently from 0739407 to 9298e48 Compare July 10, 2026 12:47
- name: Copy OAuth consumer secret to proxy
ansible.builtin.copy:
src: "{{ foreman_oauth_consumer_secret_file }}"
dest: "/root/foreman-oauth-consumer-secret"

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 don't love this. Copying and storing this value at /root. I think these need to go into the state directory or include them in the bundle.

@arvind4501 arvind4501 Jul 13, 2026

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.

This causes CI failure, because(in context of controller and target), we have single controller managing both quadlet and proxy targets in Dev and CI. but thats not the case on production, there we have separate proxy machine which itself acts as controller so we need to copy oauth credentials and certificates bundle from foreman machine.

@arvind4501
arvind4501 force-pushed the prepare-proxy branch 3 times, most recently from 619d463 to 6ba812e Compare July 13, 2026 08:28
- name: Prepare proxy host
run: |
./forge fetch-bundle proxy.example.com
./foremanctl prepare-proxy proxy.example.com

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.

Instead of introducing a new subcommand just for preparation, could we leverage the existing one — something like foremanctl deploy-proxy --prepare, I'd like to understand the reasoning behind this design, what led us to prefer a new subcommand over extending the existing one?
Adding a separate subcommand for each step feels like unnecessary from the user's perspective.

@arvind4501 arvind4501 Jul 16, 2026

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.

my reasoning to pick a separate prepare-proxy command is that it keeps two distinct tasks seprate as below:-

  • preparing proxy machine for deployment
  • actually deploying proxy

Adding a separate subcommand for each step feels like unnecessary from the user's perspective.

we are not adding subcommand for each task here rather prepare-proxy is the bundle of tasks(copying oauth credentials and certificate bundle) that helps to take care of the whole prepration we need to deploy the proxy.

Comment on lines +61 to +67
- name: Copy OAuth consumer secret to proxy
ansible.builtin.copy:
src: "{{ foreman_oauth_consumer_secret_file }}"
dest: "{{ obsah_state_path }}/foreman-oauth-consumer-secret"
mode: "0600"
owner: root
group: root

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.

Once the certificate bundle and OAuth keys are copied, could we also print a ready-to-run foremanctl deploy-proxy.. command to the console? This would mirror the experience users are familiar with from
capsule-certs-generate, which outputs the exact install command with all the necessary parameters filled in.

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.

we could, yes, but i think after copying we eliminate the need of passing oauth credentianls(directly slurp from copied path) so essentially user only need to pass certificate bundle and foreman fqdn

@ehelms

ehelms commented Jul 18, 2026

Copy link
Copy Markdown
Member

@arvind4501 Could you add docs updates? That would help understand the user flow.

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.

4 participants