Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refs #37601 - Refresh/deploy CA cert on hosts #3193

Merged
merged 26 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
b65004d
Add CA cert refreshing on hosts
Lennonka Aug 8, 2024
52cc5ed
Snippetize verification
Lennonka Aug 8, 2024
bd2b01a
fixup! Add CA cert refreshing on hosts
Lennonka Aug 8, 2024
f5aba4f
fixup! Add CA cert refreshing on hosts
Lennonka Aug 8, 2024
cb907b4
Prefix commands with hash char
Lennonka Aug 12, 2024
d9e355c
Reduce command output
Lennonka Aug 12, 2024
2e6e896
Use long argument
Lennonka Aug 12, 2024
3a7de44
Refactor renewing certs chapter
Lennonka Aug 13, 2024
686369d
Use refreshing to update CA cert
Lennonka Aug 13, 2024
af15683
Add CA cert renewal procedure
Lennonka Aug 13, 2024
6512492
Improve wording
Lennonka Aug 13, 2024
4dd7a59
Refactor CA renewal
Lennonka Aug 13, 2024
d51a1c5
fixup! Refactor CA renewal
Lennonka Aug 13, 2024
c651686
Fixup
Lennonka Aug 13, 2024
a1015fb
Apply suggestions from code review
Lennonka Aug 19, 2024
06fb887
Move cert change and link to prerequisite
Lennonka Aug 19, 2024
dbd3d23
Incorporate feedback
Lennonka Aug 19, 2024
34f6cb2
Apply suggestions from code review
Lennonka Aug 20, 2024
2ed16d1
Verify for SmartProxy
Lennonka Aug 20, 2024
b9eacad
Snippetize prerequisites
Lennonka Aug 20, 2024
9077418
Remove line that is in Prereqs
Lennonka Aug 20, 2024
2691633
Add a missing article
Lennonka Aug 29, 2024
0d642e7
Snippetize replace FQDN
Lennonka Aug 29, 2024
8c97d53
Incorporate suggestions from review
Lennonka Sep 2, 2024
8a8ba3c
Incorporate suggestions from review
Lennonka Sep 2, 2024
3568f89
Add self-signed to module titles
Lennonka Sep 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Lennonka marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
include::modules/con_refreshing-the-ca-certificate-on-hosts.adoc[]

ifdef::katello,orcharhino,satellite[]
include::modules/proc_deploying-the-ca-certificate-on-a-host-by-using-script-rex.adoc[leveloffset=+1]

include::modules/proc_deploying-the-ca-certificate-on-a-host-by-using-ansible-rex.adoc[leveloffset=+1]
endif::[]

include::modules/proc_deploying-the-ca-certificate-on-a-host-manually.adoc[leveloffset=+1]
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
include::modules/con_renewing-the-custom-ssl-certificate.adoc[]
include::modules/con_renewing-certificates.adoc[]

include::modules/proc_planning-for-ca-certificate-renewal.adoc[leveloffset=+1]

include::modules/proc_renewing-a-custom-ssl-certificate-on-server.adoc[leveloffset=+1]

Expand Down
Lennonka marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[id="refreshing-the-ca-certificate-on-hosts"]
= Refreshing the CA certificate on hosts

When you change the CA certificate on your {ProjectServer}, you must refresh the CA certificate on your hosts.

Ensure that you use a temporary dual CA certificate file for uninterrupted operation.
For more information, see {AdministeringDocURL}planning-for-ca-certificate-renewal[Planning for CA certificate renewal] in _{AdministeringDocTitle}_.

ifdef::katello,orcharhino,satellite[]
If you have already changed the CA certificate on {ProjectServer} without using the temporary dual CA certificate file, you must refresh the certificate on hosts manually because the scripted variant will not recognize {ProjectServer}.
endif::[]
4 changes: 4 additions & 0 deletions guides/common/modules/con_renewing-certificates.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[id="renewing-certificates"]
= Renewing certificates

You can renew the CA certificate on {ProjectServer} or the {customssl} certificate on {ProjectServer} as well as on {SmartProxyServer}.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
[id="deploying-the-ca-certificate-on-a-host-by-using-ansible-rex"]
= Deploying the CA certificate on a host by using Ansible REX
Lennonka marked this conversation as resolved.
Show resolved Hide resolved

You can use remote execution (REX) with the Ansible provider to deploy the CA certificate.
Lennonka marked this conversation as resolved.
Show resolved Hide resolved

include::snip_prerequisites-deploying-ca-cert-rex.adoc[]

.Procedure
. In the {ProjectWebUI}, navigate to *Monitor* > *Jobs*.
. Click *Run Job*.
. From the *Job category* list, select `Ansible Commands`.
. From the *Job template* list, select `Download and execute a script`.
. Click *Next*.
. Select hosts on which you want to execute the job.
. In the *url* field, enter the following URL:
+
[options="nowrap" subs="+quotes,verbatim,attributes"]
----
https://_{foreman-example-com}_/unattended/public/foreman_ca_refresh
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you go this route, you must mention that for isolated hosts this must be retrieved via a Smart Proxy (AKA Capsule) because they may not be able to access Foreman.

It would be better to implement a dedicated REX job template and that the user selects. Then the user doesn't need to input any fields and we can rely on REX to properly transfer the script. Even if the certificate expired (because SSH push mode doesn't need them) and when the host is isolated.

The same goes for the Script REX procedure.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be better to implement a dedicated REX job template and that the user selects. Then the user doesn't need to input any fields and we can rely on REX to properly transfer the script. Even if the certificate expired (because SSH push mode doesn't need them) and when the host is isolated.
The same goes for the Script REX procedure.

Created a tracker to properly track it: https://projects.theforeman.org/issues/37773

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ekohl with our dropping of API access in the reverse proxy, will isolated hosts have access to this endpoint? do we need to add this endpoint to our list of allowed endpoints?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ekohl with our dropping of API access in the reverse proxy, will isolated hosts have access to this endpoint? do we need to add this endpoint to our list of allowed endpoints?

We already have the templates module which proxies the unattended templates (also for kickstarts etc). I think the current API should cover it, but not 100% sure. This needs to be verified.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ekohl Almost. We are missing get "/:kind/:template" do variant to get it working

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

----
+
Replace _{foreman-example-com}_ with the hostname of your {ProjectServer}.
Lennonka marked this conversation as resolved.
Show resolved Hide resolved
+
You can use HTTP when the CA certificate is expired.
However, {Team} recommends preparing the certificate renewal in advance.
Lennonka marked this conversation as resolved.
Show resolved Hide resolved
. Optional: Click *Next* and configure advanced fields and scheduling as you require.
. Click *Run on selected hosts*.

include::snip_verification-ca-set-correctly.adoc[]

[role="_additional-resources"]
.Additional resources
* xref:executing-a-remote-job_managing-hosts[]
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
[id="deploying-the-ca-certificate-on-a-host-by-using-script-rex"]
= Deploying the CA certificate on a host by using Script REX

You can use remote execution (REX) with the Script provider to deploy the CA certificate.

include::snip_prerequisites-deploying-ca-cert-rex.adoc[]

.Procedure
. In the {ProjectWebUI}, navigate to *Monitor* > *Jobs*.
. Click *Run Job*.
. From the *Job category* list, select `Commands`.
Copy link
Contributor

@apinnick apinnick Nov 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Lennonka I realize that this has already been merged. I found this PR when I was trying to figure out the RN for this feature. UI elements and options should be marked up as bold, not with backticks.

. From the *Job template* list, select `Download and run a script`.
. Click *Next*.
. Select hosts on which you want to execute the job.
. In the *url* field, enter the following URL:
+
[options="nowrap" subs="+quotes,verbatim,attributes"]
----
https://_{foreman-example-com}_/unattended/public/foreman_ca_refresh
Lennonka marked this conversation as resolved.
Show resolved Hide resolved
----
+
Replace _{foreman-example-com}_ with the hostname of your {ProjectServer}.
+
You can use HTTP when the CA certificate is expired.
However, {Team} recommends preparing the certificate renewal in advance.
. Optional: Click *Next* and configure advanced fields and scheduling as you require.
. Click *Run on selected hosts*.

include::snip_verification-ca-set-correctly.adoc[]

[role="_additional-resources"]
.Additional resources
* xref:executing-a-remote-job_managing-hosts[]
Lennonka marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
[id="deploying-the-ca-certificate-on-a-host-manually"]
= Deploying the CA certificate on a host manually
Lennonka marked this conversation as resolved.
Show resolved Hide resolved

You can deploy the CA certificate on the host manually by rendering a public provisioning template, which will provide the certificate to your host.

.Prerequisites
* You have root access on your host.
* The CA certificate has been changed on {ProjectServer}.
For more information, see {AdministeringDocURL}planning-for-ca-certificate-renewal[Planning for CA certificate renewal] in _{AdministeringDocTitle}_.

.Procedure
. Log in to you host by using SSH.
Lennonka marked this conversation as resolved.
Show resolved Hide resolved
. Download the certificate on your host:
Lennonka marked this conversation as resolved.
Show resolved Hide resolved
+
[options="nowrap" subs="+quotes,verbatim,attributes"]
----
# curl -o "{project-context}_ca_cert.crt" https://_{foreman-example-com}_/unattended/public/foreman_raw_ca
----
+
Replace _{foreman-example-com}_ with the hostname of your {ProjectServer}.
+
You can use HTTP when the CA certificate is expired.
However, {Team} recommends preparing the certificate renewal in advance.
. Copy the certificate to the truststore:
ifdef::client-content-dnf[]
ifndef::satellite[]
* On {EL}:
endif::[]
+
[options="nowrap" subs="+quotes,verbatim,attributes"]
----
# cp {project-context}_ca_cert.crt /etc/pki/ca-trust/source/anchors
Lennonka marked this conversation as resolved.
Show resolved Hide resolved
----
endif::[]
ifdef::client-content-apt[]
maximiliankolb marked this conversation as resolved.
Show resolved Hide resolved
* On {DL}:
+
[options="nowrap" subs="+quotes,verbatim,attributes"]
----
# cp {project-context}_ca_cert.crt /usr/local/share/ca-certificates/
----
endif::[]
. Update the truststore:
ifdef::client-content-dnf[]
ifndef::satellite[]
* On {EL}:
endif::[]
Lennonka marked this conversation as resolved.
Show resolved Hide resolved
+
[options="nowrap" subs="+quotes,verbatim,attributes"]
----
# update-ca-trust
----
endif::[]
ifdef::client-content-apt[]
* On {DL}:
+
[options="nowrap" subs="+quotes,verbatim,attributes"]
----
# update-ca-certificates
----
endif::[]

include::snip_verification-ca-set-correctly.adoc[]
Lennonka marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[id="planning-for-ca-certificate-renewal"]
= Planning for CA certificate renewal

If you need to update the Certification Authority (CA) certificate on your {ProjectServer}, add the new CA certificate and use a temporary dual CA certificate file to retain the HTTPS connections to your {ProjectServer} during the renewal.

.Procedure
. Add the new SSL certificate to the CA certificate file on {ProjectServer} and keep the old SSL certificate.
. Renew the certificates on {ProjectServer} and any {SmartProxyServers}.
. Deploy the dual CA certificate on hosts.
. Remove the old certificate from the CA certificates file on {ProjectServer}, so the CA certificate file contains only the new SSL certificate.
. Renew the certificates on {ProjectServer} and any {SmartProxyServers}.
. Deploy the new CA certificate on hosts.

[role="_additional-resources"]
.Additional resources
* {ManagingHostsDocURL}refreshing-the-ca-certificate-on-hosts[Refreshing the CA certificate on hosts] in _{ManagingHostsDocTitle}_
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,11 @@ Do not delete the certificate files after you deploy the certificate.
They are required when upgrading {ProjectServer}.
====

[NOTE]
====
If a new consumer package `katello-ca-consumer-latest.noarch.rpm` is generated due to a different Certificate Signing Authority, all the clients registered to {ProjectServer} must be updated.
====

.Verification
. Access the {ProjectWebUI} from your local machine.
For example, https://{foreman-example-com}.
For example, `https://{foreman-example-com}`.
. In your browser, view the certificate details to verify the deployed certificate.

.Next steps
* If you have changed the CA certificate on {ProjectServer}, refresh the CA certificate on your hosts.
Lennonka marked this conversation as resolved.
Show resolved Hide resolved
For more information, see {ManagingHostsDocURL}refreshing-the-ca-certificate-on-hosts[Refreshing the CA certificate on hosts] in _{ManagingHostsDocTitle}_.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ Do not delete the certificate archive file on the {SmartProxyServer} after you d
They are required when upgrading {SmartProxyServer}.
====

[NOTE]
====
If a new consumer package `katello-ca-consumer-latest.noarch.rpm` is generated due to a different Certificate Signing Authority, all the clients registered to {SmartProxyServer} must be updated.
====
.Next steps
* If you have changed the CA certificate on {ProjectServer}, refresh the CA certificate on your hosts.
For more information, see {ManagingHostsDocURL}refreshing-the-ca-certificate-on-hosts[Refreshing the CA certificate on hosts] in _{ManagingHostsDocTitle}_.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.Prerequisites
* The host is registered to {Project}.
* Remote execution is enabled on the host.
* The CA certificate has been changed on {ProjectServer}.
For more information, see {AdministeringDocURL}planning-for-ca-certificate-renewal[Planning for CA certificate renewal] in _{AdministeringDocTitle}_.
20 changes: 20 additions & 0 deletions guides/common/modules/snip_verification-ca-set-correctly.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
.Verification
* If the host can access {ProjectServer}, the following command succeeds on your host:
+
[options="nowrap" subs="+quotes,verbatim,attributes"]
----
$ curl --head https://_{foreman-example-com}_
----
+
Replace _{foreman-example-com}_ with the hostname of your {ProjectServer}.
Lennonka marked this conversation as resolved.
Show resolved Hide resolved
* If the host can access {SmartProxyServer}, the following command succeeds on your host:
+
[options="nowrap" subs="+quotes,verbatim,attributes"]
----
$ curl --head https://_{smartproxy-example-com}:{smartproxy_port}_/features
----
+
Replace _{smartproxy-example-com}_ with the hostname of your {SmartProxyServer}.
ifndef::satellite[]
Replace the port number with the port number you use.
endif::[]
2 changes: 1 addition & 1 deletion guides/doc-Administering_Project/master.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ endif::[]
include::common/assembly_maintaining-server.adoc[leveloffset=+1]

ifdef::katello,orcharhino,satellite[]
include::common/assembly_renewing-custom-ssl-certificate.adoc[leveloffset=+1]
include::common/assembly_renewing-certificates.adoc[leveloffset=+1]
endif::[]

include::common/assembly_synchronizing-template-repositories.adoc[leveloffset=+1]
Expand Down
2 changes: 2 additions & 0 deletions guides/doc-Managing_Hosts/master.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ include::common/assembly_registering-hosts.adoc[leveloffset=+1]

include::common/assembly_managing-network-interfaces.adoc[leveloffset=+1]

include::common/assembly_refreshing-the-ca-certificate-on-hosts.adoc[leveloffset=+1]

include::common/modules/proc_upgrading-hosts-to-next-major-release.adoc[leveloffset=+1]

include::common/assembly_converting-a-host-to-rhel.adoc[leveloffset=+1]
Expand Down