Auto-detect and normalize installer certificates#421
Conversation
252977b to
28bad69
Compare
28bad69 to
da1cd29
Compare
|
@ehelms could you please rebase this one |
e96db39 to
5d8e7a7
Compare
|
certs-check is right, "TASK [certificates : Sign server certificate] **********************************" did re-sign the cert, it really should not for "custom" certs, those can't be managed by us. |
552ddf4 to
5d317ef
Compare
a7444fc to
dfde810
Compare
|
The more I think about it, the more I think and the |
|
I agree I can now pull out the custom certificates to their own PR. And that, installer certificates via migration handling makes more sense as a one time operation. Do you generally agree on the direction of installer certs support? That is should be "converted" so |
|
Custom certificate handling now exists at: #462 |
Yes, as the setup (well, at the very least the CA) need to be fully usable in foremanctl to deploy new proxies etc. |
dfde810 to
93f61e8
Compare
93f61e8 to
0807995
Compare
0807995 to
b14f1a8
Compare
b14f1a8 to
608ae7b
Compare
58abec2 to
9ae734c
Compare
| - name: Backup installer certificate directory | ||
| ansible.builtin.copy: | ||
| src: /root/ssl-build/ | ||
| dest: /root/ssl-build.bak/ | ||
| remote_src: true | ||
| mode: preserve | ||
|
|
||
| - name: Remove original installer certificate directory | ||
| ansible.builtin.file: | ||
| path: /root/ssl-build | ||
| state: absent |
There was a problem hiding this comment.
Can/should this be a command: mv? Neither seems too Ansible-style to me, but I wanted to ask.
| _unmappable_warning: "Warning: {{ migration_result.unmappable | length }} parameter(s) could not be mapped - see warnings above" | ||
| _output_file_msg: "Output written to: {{ migration_result.output_file }}" | ||
|
|
||
| - name: Migrate foreman-installer certificates |
There was a problem hiding this comment.
Given this alters the system, should it be behind a flag? Users might want to call foremanctl migrate many times before they are satisfied with the answers-migration.
e3c7d8b to
7029edb
Compare
This is still happening. The CA private key remains stable, but the self-signed cert is updated (from The problem is that the CSR doesn't match anymore (different CN etc), and this triggers a regeneration of the cert. Logical, but painful. |
The default and custom_server certificate vars files defined identical paths since custom certificates are normalized into the same directory structure during deployment. Remove the vars file indirection and use a single certificates.yml for all certificate sources. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Guard all CA artifact tasks in the certificates role with certificates_renew_ca (default: false). Without this, the default openssl_privatekey regenerate behavior (full_idempotence) replaces an existing CA key when the passphrase differs — which breaks post-migration deploys where the installer CA uses a different passphrase. With certificates_renew_ca: false, the CA key uses regenerate: never and all other CA tasks (password file, CSR, certificate, server-ca, ca-bundle) use force: false. Setting certificates_renew_ca: true restores full regeneration for explicit CA renewal. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Move foreman-installer certificate normalization into the migrate subcommand so it runs once during migration rather than on every deploy. The migrate_foreman_installer role copies certs from /root/ssl-build/ into /var/lib/foremanctl/certs/, persists the CA passphrase to a dedicated file, and backs up the original directory. Detect custom server certificates by comparing the internal CA with the server CA. When they differ, persist certificates_source: custom_server to prevent subsequent deploys from overwriting the custom server cert. Remove the installer certificate source since migrated certs use the default source paths after normalization. Mark certificate path parameters as IGNORE in the answer file migration since the role handles cert files directly. Separate I/O from the migrate_answers module so it only transforms and returns mapped parameters. The playbook handles writing to stdout, output files, and the parameters file. Migration is preview-by-default and requires --apply to perform changes. Update integration tests to read control-node state files from OBSAH_STATE rather than hardcoding paths or checking the remote server. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
81dd6e5 to
dd84cb2
Compare
|
|
||
| - name: Persist CA password to foremanctl configuration | ||
| ansible.builtin.copy: | ||
| dest: "{{ obsah_state_path }}/certificates-ca-password" |
There was a problem hiding this comment.
Can't we use certificates_ca_password_file here?
8dc35b4 to
19de38a
Compare
Why are you introducing these changes? (Problem description, related links)
Migrating from a foreman-installer deployment to foremanctl requires converting
both the answer file parameters and the certificate layout. Previously this had
to be done manually. The
migratesubcommand now handles this in a single step,but the migrate playbook was running without elevated privileges, causing a
permission error when reading
/etc/foreman-installer/files.What are the changes introduced in this pull request?
migrate_foreman_installerrole that runs duringforemanctl migratetocopy certificates from
/root/ssl-build/into/root/certificates/, persistthe CA passphrase into
parameters.yaml, and back up the original directorythe server CA; write
certificates_source: custom_servertoparameters.yamlwhen they differ so subsequent deploys do not overwrite the custom cert
source paths after normalization; mark certificate path parameters as
IGNOREin answer file migration since the role handles cert files directly
default_certificates.ymlandcustom_server_certificates.ymlinto a single
certificates.yml(paths were identical after normalization)foreman-installer, run
foremanctl migrate, deploy, and testbecome: trueto theanswer file migration play so the module can read files under
/etc/foreman-installer/How to test this pull request
Steps to reproduce:
foremanctl migrateand confirm a valid
parameters.yamlis produced and certs are copied into placecertificates_source: custom_serverwritten to
parameters.yamlforemanctl deployafter migration and confirm it succeeds withoutre-running certificate migration
Checklist