Chapter 3. Installing the Ansible plug-ins with the Operator on OpenShift Container Platform
The following procedures describe how to install Ansible plug-ins in Red Hat Developer Hub instances on Red Hat OpenShift Container Platform using the Operator.
3.1. Prerequisites Copy linkLink copied to clipboard!
Red Hat Developer Hub installed on Red Hat OpenShift Container Platform.
- For Helm installation, follow the steps in the Installing Red Hat Developer Hub on OpenShift Container Platform with the Helm chart section of Installing Red Hat Developer Hub on OpenShift Container Platform.
- For Operator installation, follow the steps in the Installing Red Hat Developer Hub on OpenShift Container Platform with the Operator section of Installing Red Hat Developer Hub on OpenShift Container Platform.
- A valid subscription to Red Hat Ansible Automation Platform.
- An OpenShift Container Platform instance with the appropriate permissions within your project to create an application.
- The Red Hat Developer Hub instance can query the automation controller API.
- Optional: To use the integrated learning paths, you must have outbound access to developers.redhat.com.
3.2. Recommended RHDH preconfiguration Copy linkLink copied to clipboard!
Red Hat recommends performing the following initial configuration tasks in RHDH. However, you can install the Ansible plug-ins for Red Hat Developer Hub before completing these tasks.
Red Hat provides a repository of software templates for RHDH that uses the publish:github action. To use these software templates, you must install the required GitHub dynamic plugins.
3.3. Adding a sidecar container for Ansible development tools to the RHDH Operator Custom Resource Copy linkLink copied to clipboard!
Add a sidecar container for Ansible development tools in the Developer Hub pod. To do this, you must modify the base ConfigMap for the Red Hat Developer Hub deployment.
- In the OpenShift console, select the Topology view.
- Click More actions ⋮ on the developer-hub instance and select Edit backstage to open the Backstage details page.
- Select the YAML tab.
In the editing pane, add a
containersblock in thespec.deployment.patch.spec.template.specblock:Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Click .
If you want to add extra environment variables to your deployment, you can add them in the spec.application.extraEnvs block:
3.4. Downloading the Ansible plug-ins files Copy linkLink copied to clipboard!
- In a browser, navigate to the Red Hat Ansible Automation Platform Product Software downloads page. and select the Product Software tab.
Click Download now next to Ansible plug-ins for Red Hat Developer Hub Setup Bundle to download the latest version of the plug-ins.
The format of the filename is
ansible-rhdh-plugins-x.y.z.tar.gz. Substitute the Ansible plug-ins release version, for example2.0.0, forx.y.z.Create a directory on your local machine to store the
.tarfiles.mkdir /path/to/<ansible-backstage-plugins-local-dir-changeme>
$ mkdir /path/to/<ansible-backstage-plugins-local-dir-changeme>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set an environment variable (
$DYNAMIC_PLUGIN_ROOT_DIR) to represent the directory path.export DYNAMIC_PLUGIN_ROOT_DIR=/path/to/<ansible-backstage-plugins-local-dir-changeme>
$ export DYNAMIC_PLUGIN_ROOT_DIR=/path/to/<ansible-backstage-plugins-local-dir-changeme>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Extract the
ansible-rhdh-plugins-<version-number>.tar.gzcontents to$DYNAMIC_PLUGIN_ROOT_DIR.tar --exclude='*code*' -xzf ansible-rhdh-plugins-x.y.z.tar.gz -C $DYNAMIC_PLUGIN_ROOT_DIR
$ tar --exclude='*code*' -xzf ansible-rhdh-plugins-x.y.z.tar.gz -C $DYNAMIC_PLUGIN_ROOT_DIRCopy to Clipboard Copied! Toggle word wrap Toggle overflow Substitute the Ansible plug-ins release version, for example
2.0.0, forx.y.z.
Verification
Run ls to verify that the extracted files are in the $DYNAMIC_PLUGIN_ROOT_DIR directory:
ls $DYNAMIC_PLUGIN_ROOT_DIR ansible-plugin-backstage-rhaap-dynamic-x.y.z.tgz ansible-plugin-backstage-rhaap-dynamic-x.y.z.tgz.integrity ansible-plugin-scaffolder-backend-module-backstage-rhaap-dynamic-x.y.z.tgz ansible-plugin-scaffolder-backend-module-backstage-rhaap-dynamic-x.y.z.tgz.integrity
$ ls $DYNAMIC_PLUGIN_ROOT_DIR
ansible-plugin-backstage-rhaap-dynamic-x.y.z.tgz
ansible-plugin-backstage-rhaap-dynamic-x.y.z.tgz.integrity
ansible-plugin-scaffolder-backend-module-backstage-rhaap-dynamic-x.y.z.tgz
ansible-plugin-scaffolder-backend-module-backstage-rhaap-dynamic-x.y.z.tgz.integrity
The files with the .integrity file type contain the plugin SHA value. The SHA value is used during the plug-in configuration.
3.5. Creating a registry for the Ansible plug-ins Copy linkLink copied to clipboard!
Set up a registry in your OpenShift cluster to host the Ansible plug-ins and make them available for installation in Red Hat Developer Hub (RHDH).
Procedure
- Log in to your OpenShift Container Platform instance with credentials to create a new application.
Open your Red Hat Developer Hub OpenShift project.
oc project <YOUR_DEVELOPER_HUB_PROJECT>
$ oc project <YOUR_DEVELOPER_HUB_PROJECT>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Run the following commands to create a plug-in registry build in the OpenShift cluster.
oc new-build httpd --name=plugin-registry --binary oc start-build plugin-registry --from-dir=$DYNAMIC_PLUGIN_ROOT_DIR --wait oc new-app --image-stream=plugin-registry
$ oc new-build httpd --name=plugin-registry --binary $ oc start-build plugin-registry --from-dir=$DYNAMIC_PLUGIN_ROOT_DIR --wait $ oc new-app --image-stream=plugin-registryCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Verification
To verify that the plugin-registry was deployed successfully, open the Topology view in the Developer perspective on the Red Hat Developer Hub application in the OpenShift Web console.
Click the plug-in registry to view the log.
(1) Developer hub instance
(2) Plug-in registry
- Click the terminal tab and login to the container.
In the terminal, run
lsto confirm that the.tarfiles are in the plugin registry.ansible-plugin-backstage-rhaap-dynamic-x.y.z.tgz ansible-plugin-scaffolder-backend-module-backstage-rhaap-dynamic-x.y.z.tgz
ansible-plugin-backstage-rhaap-dynamic-x.y.z.tgz ansible-plugin-scaffolder-backend-module-backstage-rhaap-dynamic-x.y.z.tgzCopy to Clipboard Copied! Toggle word wrap Toggle overflow The version numbers and file names can differ.
3.6. Installing the dynamic plug-ins Copy linkLink copied to clipboard!
To install the dynamic plugins, add them to your ConfigMap for your RHDH plugin settings (for example, rhaap-dynamic-plugins-config).
If you have not already created a ConfigMap file for your RHDH plugin settings, create one by following the procedure in the Creating and using config maps section of the OpenShift Container Platform Nodes guide.
The example ConfigMap used in the following procedure is called rhaap-dynamic-plugins-config.
Procedure
- Select ConfigMaps in the navigation pane of the OpenShift console.
-
Select the
rhaap-dynamic-plugins-configConfigMap from the list. -
Select the YAML tab to edit the
rhaap-dynamic-plugins-configConfigMap. In the
data.dynamic-plugins.yaml.pluginsblock, add the three dynamic plug-ins from the plug-in registry.-
For the
integrityhash values, use the.integrityfiles in your$DYNAMIC_PLUGIN_ROOT_DIRdirectory that correspond to each plug-in, for example useansible-plugin-backstage-rhaap-dynamic-x.y.z.tgz.integrityfor theansible-plugin-backstage-rhaap-dynamic-x.y.z.tgzplug-in. Replace
x.y.zwith the correct version of the plug-ins.Copy to Clipboard Copied! Toggle word wrap Toggle overflow
-
For the
- Click .
To view the progress of the rolling restart:
- In the Topology view, select the deployment pod and click View logs.
-
Select
install-dynamic-pluginsfrom the list of containers.
Verification
- In the OpenShift console, select the Topology view.
- Click the Open URL icon on the deployment pod to open your Red Hat Developer Hub instance in a browser window.
The Ansible plug-in is present in the navigation pane, and if you select Administration, the installed plug-ins are listed in the Plugins tab.
3.7. Adding a custom ConfigMap Copy linkLink copied to clipboard!
Create a Red Hat Developer Hub ConfigMap following the procedure in the Creating and using config maps section of the OpenShift Container Platform Nodes guide. The following examples use a custom ConfigMap named app-config-rhdh.
To edit your custom ConfigMap, log in to the OpenShift UI and navigate to
3.8. Configuring the Ansible Dev Tools Server Copy linkLink copied to clipboard!
The creatorService URL is required for the Ansible plug-ins to provision new projects using the provided software templates.
Procedure
-
Edit your custom Red Hat Developer Hub config map,
app-config-rhdh, that you created in Adding a custom ConfigMap. Add the following code to your Red Hat Developer Hub
app-config-rhdh.yamlfile.Copy to Clipboard Copied! Toggle word wrap Toggle overflow
3.9. Configuring Ansible Automation Platform details Copy linkLink copied to clipboard!
The Ansible plug-ins query your Ansible Automation Platform subscription status with the controller API using a token.
The Ansible plug-ins continue to function regardless of the Ansible Automation Platform subscription status.
Procedure
- Create a Personal Access Token (PAT) with “Read” scope in automation controller, following the Applications section of Access management and authentication.
-
Edit your custom Red Hat Developer Hub config map, for example
app-config-rhdh. Add your Ansible Automation Platform details to
app-config-rhdh.yaml.-
Set the
baseURLkey with your automation controller URL. -
Set the
tokenkey with the generated token value that you created in Step 1. Set the
checkSSLkey totrueorfalse.If
checkSSLis set totrue, the Ansible plug-ins verify whether the SSL certificate is valid.Copy to Clipboard Copied! Toggle word wrap Toggle overflow
-
Set the
You are responsible for protecting your Red Hat Developer Hub installation from external and unauthorized access. Manage the backend authentication key like any other secret. Meet strong password requirements, do not expose it in any configuration files, and only inject it into configuration files as an environment variable.
3.10. Adding Ansible plug-ins software templates Copy linkLink copied to clipboard!
Red Hat Ansible provides software templates for Red Hat Developer Hub to provision new playbooks and collection projects based on Ansible best practices.
Procedure
-
Edit your custom Red Hat Developer Hub config map, for example
app-config-rhdh. Add the following code to your Red Hat Developer Hub
app-config-rhdh.yamlfile.Copy to Clipboard Copied! Toggle word wrap Toggle overflow
3.11. Configuring Role Based Access Control Copy linkLink copied to clipboard!
Red Hat Developer Hub offers Role-based Access Control (RBAC) functionality. RBAC can then be applied to the Ansible plug-ins content.
Assign the following roles:
-
Members of the
admin:superUsersgroup can select templates in the Create tab of the Ansible plug-ins to create playbook and collection projects. -
Members of the
admin:usersgroup can view templates in the Create tab of the Ansible plug-ins.
The following example adds RBAC to Red Hat Developer Hub.
For more information about permission policies and managing RBAC, refer to the Authorization in Red Hat Developer Hub guide for Red Hat Developer Hub.
3.12. Optional configuration for Ansible plug-ins Copy linkLink copied to clipboard!
3.12.1. Enabling Red Hat Developer Hub authentication Copy linkLink copied to clipboard!
Red Hat Developer Hub (RHDH) provides integrations for multiple Source Control Management (SCM) systems. This is required by the plug-ins to create repositories.
Refer to the Enabling authentication in Red Hat Developer Hub chapter of the Administration guide for Red Hat Developer Hub.
3.12.2. Configuring Ansible plug-ins optional integrations Copy linkLink copied to clipboard!
The Ansible plug-ins provide integrations with Ansible Automation Platform and other optional Red Hat products.
To edit your custom ConfigMap, log in to the OpenShift UI and navigate to
3.12.2.1. Configuring OpenShift Dev Spaces Copy linkLink copied to clipboard!
When OpenShift Dev Spaces is configured for the Ansible plug-ins, users can click a link from the catalog item view in Red Hat Developer Hub and edit their provisioned Ansible Git projects using Dev Spaces.
OpenShift Dev Spaces is a separate product and it is optional. The plug-ins will function without it.
It is a separate Red Hat product and is not included in the Ansible Automation Platform or Red Hat Developer Hub subscription.
If the OpenShift Dev Spaces link is not configured in the Ansible plug-ins, the Go to OpenShift Dev Spaces dashboard link in the DEVELOP section of the Ansible plug-ins landing page redirects users to the Ansible development tools home page.
Prerequisites
- A Dev Spaces installation. Refer to the Installing Dev Spaces section of the Red Hat OpenShift Dev Spaces Administration guide.
Procedure
-
Edit your custom Red Hat Developer Hub config map, for example
app-config-rhdh. Add the following code to your Red Hat Developer Hub
app-config-rhdh.yamlfile.Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
Replace
<Your OpenShft Dev Spaces URL>with your OpenShift Dev Spaces URL. -
In the OpenShift Developer UI, select the
Red Hat Developer Hubpod. - Open Actions.
- Click Restart rollout.
3.12.2.2. Configuring the private automation hub URL Copy linkLink copied to clipboard!
Private automation hub provides a centralized, on-premise repository for certified Ansible collections, execution environments and any additional, vetted content provided by your organization.
If the private automation hub URL is not configured in the Ansible plug-ins, users are redirected to the Red Hat Hybrid Cloud Console automation hub.
The private automation hub configuration is optional but recommended. The Ansible plug-ins will function without it.
Prerequisites
A private automation hub instance.
For more information on installing private automation hub, refer to the installation guides in the Ansible Automation Platform documentation.
Procedure
-
Edit your custom Red Hat Developer Hub config map, for example
app-config-rhdh. Add the following code to your Red Hat Developer Hub
app-config-rhdh.yamlfile.Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
Replace
<https://MyOwnPAHUrl/>with your private automation hub URL. -
In the OpenShift Developer UI, select the
Red Hat Developer Hubpod. - Open Actions.
- Click Restart rollout.