Chapter 7. Using Red Hat Single Sign-On Operator with automation hub
Private automation hub uses Red Hat Single Sign-On for authentication.
The Red Hat Single Sign-On Operator creates and manages resources. Use this Operator to create custom resources to automate Red Hat Single Sign-On administration in Openshift.
- When installing Ansible Automation Platform on Virtual Machines (VMs) the installer can automatically install and configure Red Hat Single Sign-On for use with private automation hub.
- When installing Ansible Automation Platform on Red Hat OpenShift Container Platform you must install Single Sign-On separately.
This chapter describes the process to configure Red Hat Single Sign-On and integrate it with private automation hub when Ansible Automation Platform is installed on OpenShift Container Platform.
Prerequisites
- You have access to Red Hat OpenShift Container Platform using an account with operator installation permissions.
- You have installed the catalog containing the Red Hat Ansible Automation Platform operators.
- You have installed the Red Hat Single Sign-On Operator. To install the Red Hat Single Sign-On Operator, follow the procedure in Installing Red Hat Single Sign-On using a custom resource in the Red Hat Single Sign-On documentation.
7.1. Creating a Keycloak instance Copy linkLink copied to clipboard!
When the Red Hat Single Sign-On Operator is installed you can create a Keycloak instance for use with Ansible Automation Platform.
From here you provide an external Postgres or one will be created for you.
Procedure
-
Navigate to
. -
Select the
rh-ssoproject. - Select the Red Hat Single Sign-On Operator.
- On the Red Hat Single Sign-On Operator details page select .
- Click .
Click .
The default Keycloak custom resource is as follows:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Click .
- When deployment is complete, you can use this credential to login to the administrative console.
-
You can find the credentials for the administrator in the
credential-<custom-resource>(example keycloak) secret in the namespace.
7.2. Creating a Keycloak realm for Ansible Automation Platform Copy linkLink copied to clipboard!
Create a realm to manage a set of users, credentials, roles, and groups. A user belongs to and logs into a realm. Realms are isolated from one another and can only manage and authenticate the users that they control.
Procedure
-
Navigate to
. - Select the Red Hat Single Sign-On Operator project.
- Select the Keycloak Realm tab and click .
On the Keycloak Realm form, select . Edit the YAML file as follows:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Expand Field
Description
metadata.nameSet a unique value in metadata for the name of the configuration resource (CR).
metadata.namespaceSet a unique value in metadata for the name of the configuration resource (CR).
metadata.labels.appSet labels to a unique value. This is used when creating the client CR.
metadata.labels.realmSet labels to a unique value. This is used when creating the client CR.
spec.realm.idSet the realm name and id. These must be the same.
spec.realm.realmSet the realm name and id. These must be the same.
spec.realm.displaynameSet the name to display.
- Click and wait for the process to complete.
7.3. Creating a Keycloak client Copy linkLink copied to clipboard!
Keycloak clients authenticate hub users with Red Hat Single Sign-On. When a user authenticates the request goes through the Keycloak client. When Single Sign-On validates or issues the OAuth token, the client provides the response to automation hub and the user can log in.
Procedure
-
Navigate to
. - Select the Red Hat Single Sign-On Operator project.
- Select the Keycloak Client tab and click .
- On the Keycloak Realm form, select .
Replace the default YAML file with the following:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- Replace this with a unique value.
- Click and wait for the process to complete.
When automation hub is deployed, you must update the client with the “Valid Redirect URIs” and “Web Origins” as described in Updating the Red Hat Single Sign-On client Additionally, the client comes pre-configured with token mappers, however, if your authentication provider does not provide group data to Red Hat SSO, then the group mapping must be updated to reflect how that information is passed. This is commonly by user attribute.
7.4. Creating a Keycloak user Copy linkLink copied to clipboard!
This procedure creates a Keycloak user, with the hubadmin role, that can log in to automation hub with Super Administration privileges.
Procedure
-
Navigate to
. - Select the Red Hat Single Sign-On Operator project.
- Select the Keycloak Realm tab and click .
- On the Keycloak User form, select .
Replace the default YAML file with the following:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Click and wait for the process to complete.
When a user is created, the Operator creates a Secret containing both the username and password using the following naming pattern: credential-<realm name>-<username>-<namespace>. In this example the credential is called credential-ansible-automation-platform-hub-admin-rh-sso. When a user is created the Operator does not update the user’s password. Password changes are not reflected in the Secret.
7.5. Creating a Red Hat Single Sign-On connection secret Copy linkLink copied to clipboard!
Use this procedure to create a connection secret for Red Hat Single Sign-On.
Procedure
-
Navigate to
https://<sso_host>/auth/realms/ansible-automation-platform. -
Copy the
public_keyvalue. -
In the OpenShift Web UI, navigate to
. - Select the ansible-automation-platform project.
- Click , and select .
Edit the following YAML to create the secret
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Click and wait for the process to complete.
7.6. Installing automation hub using the Ansible Automation Platform Operator Copy linkLink copied to clipboard!
Use the following procedure to install automation hub using the Ansible Automation Platform Operator.
Procedure
-
Navigate to
. - Select your Ansible Automation Platform Operator deployment.
- Select the Automation hub tab.
- Click .
Select . The YAML should be similar to:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- Set metadata.name to the name to use for the instance.
- 2
- Set spec.sso_secret to the name of the secret created in Creating a Secret to hold the Red Hat Single Sign On connection details.
- 3
- Scale replicas up or down for each deployment by using the
web_replicasortask_replicasrespectively, where N represents the number of replicas you want to create. Alternatively, you can scale all pods across both deployments by usingreplicas. See Scaling the Web and Task Pods independently for details.
NoteThis YAML turns off SSL verification (
ssl_verify: false). If you are not using self-signed certificates for OpenShift this setting can be removed.- Click and wait for the process to complete.
7.7. Adding allowed registries to the automation controller image configuration Copy linkLink copied to clipboard!
Before you can deploy a container image in automation hub, you must add the registry to the allowedRegistries in the automation controller image configuration. To do this you can copy and paste the following code into your automation controller image YAML.
Procedure
- Log in to Red Hat OpenShift Container Platform.
-
Navigate to
. - Select the Resources drop-down list and type "Image".
- Select Image (config,openshift.io/v1).
- Click under the Name heading.
- Select the tab.
Paste in the following under spec value:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Click .
7.8. Determining the automation hub Route Copy linkLink copied to clipboard!
Use the following procedure to determine the hub route.
Procedure
-
Navigate to
. - Select the project you used for the install.
-
Copy the location of the
private-ah-web-svcservice. The name of the service is different if you used a different name when creating the automation hub instance. This is used later to update the Red Hat Single Sign-On client.
7.9. Updating the Red Hat Single Sign-On client Copy linkLink copied to clipboard!
When automation hub is installed and you know the URL of the instance, you must update the Red Hat Single Sign-On to set the Valid Redirect URIs and Web Origins settings.
Procedure
-
Navigate to
. - Select the RH-SSO project.
- Click .
- Select .
- Click on the automation-hub-client-secret client.
- Select .
Update the Client YAML to add the Valid Redirect URIs and Web Origins settings.
redirectUris: - 'https://private-ah-ansible-automation-platform.apps-crc.testing/*' webOrigins: - 'https://private-ah-ansible-automation-platform.apps-crc.testing'
redirectUris: - 'https://private-ah-ansible-automation-platform.apps-crc.testing/*' webOrigins: - 'https://private-ah-ansible-automation-platform.apps-crc.testing'Copy to Clipboard Copied! Toggle word wrap Toggle overflow Expand Field
Description
redirectURIsThis is the location determined in Determine Automation Hub Route. Be sure to add the /* to the end of the
redirectUrissetting.webOriginsThis is the location determined in Determine Automation Hub Route.
NoteEnsure the indentation is correct when entering these settings.
- Click .
To verify connectivity
- Navigate to the automation hub route.
-
Enter the
hub_adminuser credentials and sign in. - Red Hat Single Sign-On processes the authentication and redirects back to automation hub.
7.10. Additional resources Copy linkLink copied to clipboard!
- For more information on running operators on OpenShift Container Platform, see Working with Operators in OpenShift Container Platform in the OpenShift Container Platform product documentation.