transfer oauth creds as part of certificate bundle - #698
Conversation
287645f to
ae9ce9c
Compare
|
I think it would be nice to combine the extraction into a single extraction step of the bundle for everything in it, getting placed in the right locations. |
| @@ -0,0 +1,27 @@ | |||
| --- | |||
| - name: Load OAuth credential from certificate bundle - {{ oauth_from_bundle_credential }} | |||
There was a problem hiding this comment.
The way I wanted to design the bundle was for it to be "throw away" after initial use. Can the oauth be loaded into files in the state directory and stored for reading like it is in the deploy Foreman case?
There was a problem hiding this comment.
The way it's implemented right now, the bundle.tar.gz is throw away. The reading here happens from a file on disk after extraction from a sub-folder of our state directory on the target node.
Emphasis on "target node", as that breaks the "can it be the same as Foreman" case.
In the Foreman case we store the data on the control node (lookups run on the control node), not the target node.
We could "double extract" the bundle: once the certs part on the target, and the oauth part on the controller, but I'm not sure that complexity is worth it?
There was a problem hiding this comment.
Sounds like what you are really saying is that the certificates should exist on the control node, and normalize that everything in /var/lib/foremanctl should be state?
There was a problem hiding this comment.
maaaaaaaaaaybe. (it's friday afternoon)
There was a problem hiding this comment.
is that something we need to tackle now?
|
We could switch from |
| certificate_bundle_output_directory: "{{ certificates_ca_directory }}/bundles" | ||
| certificate_bundle_server_ca_certificate: "{{ certificate_bundle_ca_certificate }}" | ||
| certificate_bundle_oauth_consumer_key_file: # noqa: no-empty-defaults | ||
| certificate_bundle_oauth_consumer_secret_file: # noqa: no-empty-defaults |
There was a problem hiding this comment.
Should we just omit these if they are empty? What's the value of having empty defaults?
There was a problem hiding this comment.
Removed them. The empty defaults only had value when paired with the when: ... is exists guards on the copy tasks, the empty value helped to safely skip tasks when caller did not provide these vars, but in our case certificate-bundle playbook always sends these vars so good to remove
| src: "{{ certificate_bundle_oauth_consumer_key_file }}" | ||
| dest: "{{ certificate_bundle_build_directory.path }}/certs/oauth/foreman-oauth-consumer-key" | ||
| mode: '0440' | ||
| when: certificate_bundle_oauth_consumer_key_file is exists |
There was a problem hiding this comment.
If this file doesn't exist should we skip over that? Or let it error? Seems fairly serious if it doesn't exist.
maybe, with that do we want to change the command from |
Given the bundle now has more than certificates, I think changing the command name makes sense. |
| - name: Generate auth bundle on quadlet | ||
| run: | | ||
| ./foremanctl certificate-bundle proxy.example.com \ | ||
| ./foremanctl auth-bundle proxy.example.com \ |
There was a problem hiding this comment.
There was a problem hiding this comment.
SatelliteQE/robottelo#22277
for doc PR, i hope to get this PR in before that 😄
Gauravtalreja1
left a comment
There was a problem hiding this comment.
ACK, Tested with foremanctl-3.0.0.develop-3.20260724120313055342.pr698.143.g745e9f5.el9.noarch 🍏
Steps: deployed Foreman server → generated auth bundle → verified OAuth files in tarball → deployed proxy without --oauth-consumer-key/secret → verified OAuth files extracted on proxy with correct permissions → confirmed proxy registered with Foreman and features refresh works → verified old CLI flags are rejected.
One minor issue found: the fail-early check for missing OAuth files doesn't trigger when using a bundle generated before this PR (old certificate-bundle), since the extraction step excludes files outside certs/ and private/, which isn't properly handled in Ansible stdout as shown below:
TASK [certificates : Extract OAuth credentials from bundle] ***********************************************************************************************************************************
fatal: [localhost]: FAILED! =>
changed: false
msg: |-
Failed to find handler for "/root/.ansible/tmp/ansible-tmp-1785238624.9872594-1828915-110760222717154/source". Make sure the required command to extract the file is installed.
Command "/usr/bin/gtar" could not handle archive: Unable to list files in the archive: tar (child): bzip2: Cannot exec: No such file or directory
tar (child): Error is not recoverable: exiting now
/usr/bin/gtar: Child returned status 2
/usr/bin/gtar: Error is not recoverable: exiting now
Command "/usr/bin/unzip" could not handle archive: End-of-central-directory signature not found. Either this file is not
a zipfile, or it constitutes one disk of a multi-part archive. In the
latter case the central directory and zipfile comment will be found on
the last disk(s) of this archive.
note: /root/.ansible/tmp/ansible-tmp-1785238624.9872594-1828915-110760222717154/source may be a plain executable, not an archive
unzip: cannot find zipfile directory in one of /root/.ansible/tmp/ansible-tmp-1785238624.9872594-1828915-110760222717154/source or
/root/.ansible/tmp/ansible-tmp-1785238624.9872594-1828915-110760222717154/source.zip, and cannot find /root/.ansible/tmp/ansible-tmp-1785238624.9872594-1828915-110760222717154/source.ZIP, period.
Command "/usr/bin/gtar" could not handle archive: Unable to list files in the archive: tar (child): zstd: Cannot exec: No such file or directory
tar (child): Error is not recoverable: exiting now
/usr/bin/gtar: Child returned status 2
/usr/bin/gtar: Error is not recoverable: exiting now
Command "/usr/bin/gtar" found no files in archive. Empty archive files are not supported.
Command "/usr/bin/gtar" could not handle archive: Unable to list files in the archive: xz: (stdin): File format not recognized
/usr/bin/gtar: Child returned status 1
/usr/bin/gtar: Error is not recoverable: exiting now
But this is a minor edge case which I discussed with @arvind4501 ; users won't have old auth-bundles in practice so we can safely ignore this.
LGTM 🍏
| Both flags are **not persisted** in foremanctl’s answers file (one-shot). | ||
|
|
||
| ### Certificate Bundle for Secondary Systems | ||
| ### Auth Bundle for Secondary Systems |
There was a problem hiding this comment.
In the parameters.md, we still show --foreman-proxy-oauth-consumer-key & --foreman-proxy-oauth-consumer-secret in the Undetermined section. Should we update that as well?
There was a problem hiding this comment.
good catch, in which section should we add droped parameters which existed on foreman-installer but not in foremanctl? or just remove them from undetermined
There was a problem hiding this comment.
In #532 I used "unmapped" to explicitly call them out. how about that?
IMHO, since bundle generation changes are not released in any version, we won't need to handle upgrades. also i expect generated bundle to have |
| | `--foreman-proxy-oauth-consumer-key` | OAuth consumer key for Smart Proxy | Not supported | | ||
| | `--foreman-proxy-oauth-consumer-secret` | OAuth consumer secret for Smart Proxy | Not supported | |
There was a problem hiding this comment.
Technically "Not required, automated", right?
Bike shedding a bit: |
when i see |
|
I like the current |
|
That's fair. Given long term I'd love to get rid of the bundle anyway I can live the |
Why are you introducing these changes? (Problem description, related links)
Proxy deployment currently requires passing
--oauth-consumer-keyand--oauth-consumer-secretmanually withdeploy-proxycommand. Those credentials already exist on the Foreman server and are required for the proxy to communicate with Foreman.With these changes oauth credentials will travel with the bundle instead of being supplied as extra CLI parameters.
What are the changes introduced in this pull request?
certificate-bundledeploy-proxy, read OAuth credentials from the extracted bundle (/var/lib/foremanctl/certs/) whenflavor == foreman-proxy-content--oauth-consumer-key/--oauth-consumer-secretfromdeploy-proxyHow to test this pull request
Steps to reproduce:
Deploy Foreman, then generate a proxy bundle:
./foremanctl auth-bundle proxy.example.comConfirm the tarball includes OAuth files:
tar -tzvf /var/lib/foremanctl/certs/bundles/proxy.example.com.tar.gz | grep oauthDeploy the proxy without OAuth CLI flags:
./foremanctl deploy-proxy --flavor foreman-proxy-content --auth-bundle <bundle> --foreman-fqdn <foreman-fqdn>Confirm extracted files exist on the proxy:
/var/lib/foremanctl/certs/foreman-oauth-consumer-keyChecklist