Using OpenShift Virtualization as an environment for hosting Virtual Machines that are provisioned, configured and maintained using Ansible and tooling from the Ansible Middleware project.
The middleware_automation.ocpv_lab
collection demonstrates the use of Ansible automation to manage both the lifecycle of Virtual Machines within an OpenShift Virtualization runtime environment as well as the installation, configuration and management of deployed instances with JBoss Enterprise Application Server (EAP).
The integration with OpenShift Virtualization illustrates how Virtual Machines within this dynamic and scalable environment can be managed similarly as other hosting environment and as Red Hat Application Services instances are a common type of workload, the use of Ansible automation showcases just how easy it is to deploy and manage an entire fleet of instances.
For this lab, the following resources must be available:
- OpenShift Container Platform
- Capable of running OpenShift Virtualization (Requirements)
cluster-admin
access
- Ansible Controller (Part of Ansible Automation Platform) deployed to the same OpenShift environment as OpenShift Virtualization.
- Control Node capable of provisioning the lab environment
- Ansible
Certain requirements must be met prior to realizing the full potential of this lab. This involves not only completing steps within a local machine (control host), but also obtaining assets from external systems.
Tooling is available within this repository to provision the lab. Clone the repository to your local machine:
git clone https://github.com/ansible-middleware/ocpv_lab.git
cd ocpv_lab
An SSH keypair is needed to communicate with the provisioned virtual machine. Provide the location of an SSH (without password) public key (.pub
) and private key within the ssh_public_key_path
and ssh_private_key_path
variables in the vars/provision.yml file.
A token for the public Automation Hub must be obtained so that it can be configured to access certified content locally as part of the setup and provisioning process as well as being stored in Ansible Controller.
Steps for obtaining the token can be found here
The token must be added to two (2) locations:
- Set the value of
token
in the ansible.cfg file - Set the value of the
automationhub_token
variables in the vars/provision.yml file
A Service Account as the associated Client ID and Client Secret must be provided so that the Runtimes assets can be generated from the Red Hat Customer Portal.
Obtain a Client ID and Client Secret by generating a Service Account here.
Set the values of the jbossnetwork_client_id
and jbossnetwork_client_secret
variables in the vars/provision.yml file.
The provisioned Virtual Machine will be subscribed so that it can obtain the required packages. Populate the redhat_csp_username
and redhat_csp_password
variables in the vars/provision.yml file with these values.
The provisioning process will configure Ansible Controller to manage the lab. The location of Controller as well as credentials must be specified. Set the controller_hostname
, controller_username
and controller_password
variables in the vars/provision.yml file.
Install the required Python dependencies by executing the following command from the root of the cloned repository:
pip install -r requirements.txt
Install the required Ansible dependencies by executing the following command from the root of the cloned repository:
ansible-galaxy collection install -r requirements.yml
Provisioning the lab performs the following actions:
- Configures Ansible Controller
- Custom Credential Types
- Credentials
- Organization
- Project
- Inventory
- Job Templates
- Deploy OCPv
- Deploy lab
Ensure that you are logged into the OpenShift environment with a user with cluster-admin
permissions and execute the following command:
ansible-playbook playbooks/provision.yml
Once the configuration of Ansible Controller has completed successfully, login to Ansible Controller and navigate to the Templates tab underneath Resources.
Deploy OpenShift Virtualization by selecting the rocketship next to the Deploy OCPv Job Template to install and configure OpenShift Virtualization.
Once OpenShift Virtualization has been installed, execute the lab. The lab provisioning process will perform the following actions:
- Create a new OpenShift namespace called
ansible-middleware-ocpv
. - Create a RHEL 9 based Virtual Machine
- Perform Dynamic discovery of VirtualMachine instance to populate an inventory group called
eap
within theocpv
inventory. - Configure the Virtual Machine with the following:
- JBoss Enterprise Application Platform 7.4.0 (and associated dependencies [OpenJDK])
- Systemd service for JBoss EAP
- Deploy a sample application and make it available at the
/info
context
- Create an OpenShift Service and Route exposing the JBoss Server
Once the automation has completed successfully, navigate to the ansible-middleware-ocpv
within the OpenShift web console.
Within Administrator perspective, expand the Networking navigation pane on the left-hand side and select Routes.
Select the eap-lab route which will open the exposed VM and present the JBoss EAP welcome page.
Navigate to the /info
context to view the deployed application.
Enjoy seeing the power of Ansible Middleware setup, configure and automate the deployment of Red Hat Runtimes within the OpenShift Container Platform!