Architecting Enterprise Automation: Integrating Ansible Automation Platform with Red Hat OpenShift

The convergence of configuration management and container orchestration represents a pivotal shift in modern infrastructure operations. By integrating Ansible—a powerful, agentless automation engine—with Red Hat OpenShift—a Kubernetes-based application platform—organizations can bridge the gap between traditional IT operations and cloud-native development. This synergy allows administrators to leverage YAML-based playbooks for the lifecycle management of clusters, the orchestration of virtualized workloads, and the deployment of complex software stacks across hybrid cloud environments. The relationship between these two technologies is bidirectional: Ansible is used to deploy and manage the OpenShift infrastructure itself, while the Ansible Automation Platform (AAP) can be hosted within OpenShift to manage other clusters, virtual machines, and off-cluster resources.

Evolutionary Trajectory of OpenShift Ansible Deployments

The methodology for installing and managing OpenShift clusters via Ansible has undergone a significant architectural shift as the platform transitioned from version 3.x to 4.x. Understanding this transition is critical for administrators managing legacy environments or planning new deployments.

Legacy 3.x Lifecycle Management

For releases in the 3.x series, Ansible playbooks served as the primary mechanism for cluster installation and configuration. The 3.11 release stands as the final iteration of the 3.x branch. In these environments, the Ansible playbooks were the definitive source of truth for the cluster's desired state, handling everything from the initial provisioning of the core operating system to the deployment of the Kubernetes control plane.

Transition to OpenShift 4.x

With the introduction of OpenShift 4.x, Red Hat shifted the installation paradigm. The heavy reliance on complex Ansible playbooks for initial installation was replaced by a dedicated command-line installation wizard known as the OpenShift Installer. This shift was designed to streamline the deployment process, reducing the manual overhead associated with inventory management and variable definition during the initial boot phase.

However, Ansible remains integral to the 4.x ecosystem for specific operational tasks. The openshift-ansible repository for 4.x is no longer used for primary installation but is instead focused on the ongoing maintenance of the cluster. Specifically, it provides the necessary playbooks for scaling up the cluster (adding new nodes) or performing upgrades on the Red Hat Enterprise Linux (RHEL) hosts within an existing 4.x environment.

Technical Implementation of openshift-ansible

For engineers utilizing the openshift-ansible toolset to manage 4.x clusters, a specific technical environment and workflow must be established. This process involves the configuration of a local control node and the definition of cluster-specific variables.

Localhost Requirements

To execute these playbooks, the management machine (localhost) must meet the following minimum software specifications: - Ansible version 2.9.5 or higher. - The OpenShift Client (oc), which provides the command-line interface needed to interact with the cluster API.

Operational Workflow for Scaling and Upgrades

Executing maintenance tasks requires a structured approach to directory navigation and command execution. The following steps detail the process for scaling and upgrading:

  1. Navigate to the repository directory: cd openshift-ansible
  2. Define the inventory: A file must be created (referencing inventory/hosts.example) that specifies the target hosts and their respective groups.
  3. Configure the kubeconfig: The variable openshift_kubeconfig_path must be defined, pointing to the path of the kubeconfig file for the target cluster. This is the administrative credential that allows Ansible to authenticate with the Kubernetes API.
  4. Execute the scaling playbook: ansible-playbook -i inventory/hosts playbooks/scaleup.yml
  5. Execute the upgrade playbook: ansible-playbook -i inventory/hosts playbooks/upgrade.yml

Customization and Extension

The upgrade process is not a monolithic operation; it is designed with hooks. These hooks allow administrators to perform custom tasks at various stages of the upgrade cycle, ensuring that third-party applications or custom configurations are preserved or updated in synchronization with the platform upgrade. For those wishing to distribute this toolset, the README_CONTAINER_IMAGE.md file provides guidance on packaging openshift-ansible as a container image, allowing for a portable, immutable automation environment.

Deploying Ansible Automation Platform on OpenShift

The integration of the Ansible Automation Platform (AAP) within an OpenShift cluster transforms the platform into a centralized automation hub. This deployment is typically managed via the Operator framework, which simplifies the lifecycle of the automation software.

Installation via OperatorHub

The most efficient path to deploying AAP is through the OperatorHub. This process involves: - Accessing the Red Hat OpenShift dashboard. - Navigating to the OperatorHub section. - Searching for and installing the Ansible Automation Platform Operator.

The Operator manages the complex deployment of the platform's core components, ensuring that they are configured correctly for the underlying Kubernetes environment. Once the operator is active, it enables the deployment of critical AAP components, including: - Automation Controller: The central engine for job scheduling, inventory management, and RBAC. - Ansible Automation Hub: A repository for managing certified content and collections. - Event-Driven Ansible: A system that triggers automation based on real-time events.

The use of an operator ensures that these components can be autoscaled and upgraded with minimal downtime, maintaining the platform's availability.

Container Groups and Execution Dynamics

A sophisticated feature of AAP on OpenShift is the use of Container Groups. These are specialized instance groups that dynamically provision pods within the OpenShift cluster to execute specific jobs.

The technical lifecycle of a container group is as follows: 1. A job is triggered in the Automation Controller. 2. A pod is provisioned on-demand within a predetermined namespace in the OpenShift cluster. 3. The playbook is executed within this pod. 4. The pod is destroyed immediately upon completion of the job.

This ephemeral nature of execution ensures that each job starts in a clean, consistent environment, eliminating "configuration drift" on the execution node and optimizing resource consumption by releasing CPU and memory immediately after the task is finished.

Hub-and-Spoke Architecture for Multi-Cluster Automation

As organizations scale their cloud-native footprint, they often adopt a "hub cluster" model. This architectural pattern centralizes management to reduce complexity and security overhead across multiple zones, data centers, and clouds.

The Hub Cluster Model

The hub cluster is a dedicated OpenShift environment located in a management segment. It hosts the centralized control plane for the entire IT operation, including: - Red Hat Ansible Automation Platform. - Red Hat Advanced Cluster Management (ACM) for Kubernetes. - Red Hat Advanced Cluster Security (ACS) for Kubernetes.

By centralizing these tools, administrators can push configurations and manage lifecycles for various "remote" or "spoke" clusters without needing to install management tooling on every single cluster.

Managing Remote OpenShift Virtualization

The rise of Red Hat OpenShift Virtualization allows organizations to run virtual machines (VMs) alongside containers. However, managing VMs across multiple remote clusters requires a coordinated automation strategy. The hub cluster model enables the Ansible Automation Platform to communicate with remote clusters to handle Day-1 (provisioning) and Day-2 (maintenance) activities.

The primary objectives of this remote communication include: - Virtual Machine Creation: Orchestrating the deployment of VMs on a remote cluster. - Post-Provisioning Tasks: Installing required software packages and starting system services via container groups. - Network Configuration: Establishing the necessary network resources to ensure the VM is reachable.

Technical Integration of Remote Clusters and Content

To enable a hub cluster to manage a remote OpenShift environment, a specific security and content framework must be implemented.

Remote Cluster Authentication and Configuration

The process of connecting the Ansible Automation Platform to a remote cluster involves the following technical steps: 1. Credential Acquisition: The administrator logs into the remote OpenShift web console, navigates to the user menu, and selects "Copy Login Command" to retrieve the OAuth token and the API server URL. 2. Service Account (SA) Creation: A dedicated Service Account must be created on the target remote cluster. This SA must be granted the necessary permissions within a specific namespace to launch automation job pods. 3. Container Group Definition: The SA token and the target namespace are added to the AAP configuration as a "Container Group." This establishes the link that allows the hub cluster to launch pods into the remote environment.

Leveraging Certified Content and Collections

The effectiveness of the automation depends on the use of certified content from the Ansible automation hub (accessible at https://console.redhat.com/ansible/automation-hub). This ensures that the modules used are supported by Red Hat and tested for compatibility.

The following collections are critical for OpenShift and Virtualization automation:

Collection Name Primary Function Key Capabilities
redhat.openshift Kubernetes Resource Management Modules for creating and managing OpenShift resources.
redhat.openshift_virtualization VM Lifecycle Management VM creation and inventory plugins for syncing VMs with Ansible hosts.
kubernetes.core Resource Information Retrieval Modules for querying status and data from the K8s API.

The redhat.openshift_virtualization collection is particularly vital as it includes an inventory plugin that allows Ansible to automatically discover virtual machines running via KubeVirt or OpenShift Virtualization, treating them as standard Ansible hosts.

Strategic Infrastructure Modernization

The combination of Ansible Automation Platform and OpenShift Virtualization provides a comprehensive solution for organizations struggling with "technology sprawl" and the high costs of legacy virtualization.

Migration of Virtual Environments

Organizations often face the challenge of outdated virtualization stacks that are costly to maintain. OpenShift Virtualization allows these organizations to migrate existing VMs into a unified application platform. By leveraging AAP, this migration can be performed consistently and at scale. Ansible can be used to automate the movement of workloads, the reconfiguration of network settings, and the validation of VM health post-migration.

Automating Off-Cluster Resources

While OpenShift focuses on the containerized environment, real-world infrastructure often includes "off-cluster" resources. These may include: - Physical network switches and firewalls. - Storage arrays. - Physical servers. - Software-as-a-Service (SaaS) tools.

By using Red Hat Advanced Cluster Management in conjunction with AAP, administrators can create unified workflows. For example, a single Ansible playbook can provision a virtual machine on an OpenShift cluster, configure a VLAN on a physical Cisco switch, and update a record in a SaaS-based DNS provider. This holistic approach ensures that the infrastructure surrounding the container platform is just as automated as the platform itself.

Summary of Configuration Requirements

For those implementing these systems, the following technical requirements and configurations are mandatory across the different layers of the architecture.

Technical Specifications Table

Component Requirement / Value Purpose
Local Management Node Ansible >= 2.9.5 Playbook execution engine
Local Management Node OpenShift Client (oc) API interaction
AAP Installation OperatorHub Automated deployment and lifecycle
Hub Cluster Management Segment Centralized control plane
Remote Cluster Service Account (SA) Permission for pod launching
Remote Cluster OAuth Token/API URL Authentication and connectivity
Content Source Ansible Automation Hub Access to certified collections

Conclusion

The integration of Ansible and Red Hat OpenShift represents a sophisticated architectural approach to the "Infrastructure as Code" (IaC) philosophy. By transitioning from the playbook-heavy installation of OpenShift 3.x to the streamlined Installer and Operator-based models of 4.x, Red Hat has shifted the focus from the act of installation to the act of continuous orchestration. The implementation of a hub-and-spoke model, powered by the Ansible Automation Platform, allows for the centralized management of disparate clusters and virtualized workloads, effectively eliminating the silos between container management and traditional VM administration.

The use of ephemeral container groups for job execution ensures that the automation environment remains pristine, while certified collections from the Automation Hub provide a stable foundation for complex operations. Ultimately, this ecosystem enables an organization to treat its entire infrastructure—whether it be a physical switch, a virtual machine, or a Kubernetes pod—as a programmable entity, drastically reducing operational overhead and accelerating the pace of digital transformation.

Sources

  1. OpenShift Ansible GitHub
  2. Red Hat - Ansible on OpenShift
  3. Red Hat Blog - Ansible Automation Platform and OpenShift Virtualization

Related Posts