DevSecOps and Automation on Power

 View Only

Create a virtual server instance in IBM Power Virtual Server using Red Hat Ansible Automation Platform

By Ashwini Kadam posted Fri December 15, 2023 10:05 AM

  
Power Developer eXchange Blog

Are you ready to dive into the dynamic realm of automation? The Red Hat Ansible Automation Platform is your gateway to streamlining IT processes. Whether it's provisioning, setup, deployment, or maintenance, Ansible has got you covered. This powerful platform simplifies tasks, empowering users to deploy applications and manage cloud infrastructure effortlessly.

What sets Red Hat Ansible Automation Platform apart is its integrated solution, making Ansible operational across your team, organization, and enterprise. The platform boasts a controller with a user-friendly web console UI, providing a comprehensive toolkit including REST API, analytics, execution environments, and much more.

The Red Hat Ansible Automation Platform offers the following features:

  • Provides role-based access control, allowing control over securely stored credentials for SSH and other services.
  • Enables synchronization of inventory with various cloud sources and supports powerful multi-playbook workflows for modeling complex processes.
  • Logs detailed information for all jobs, integrates with LDAP, SAML, and other authentication sources, and features a browsable REST API.
  • Offers various options for enrolling and working with applications through controller UI.
  • Provides command-line tools for seamless integration with Jenkins, allowing control and operation of jobs through the command line.
  • Incorporates Red Hat-supported product versions of Ansible AWX, Ansible Galaxy, and other components. 

For more information, refer to Red Hat Ansible Automation Platform on developers.redhat.com.

Why Red Hat Ansible Automation Platform?

In a world of complex IT automation, Ansible stands out as a radically simple solution. Not only does it make deployment and maintenance easier, but it's also easy to learn, self-documenting, and user-friendly.

For example, consider the need to control or operate many hosts or remote nodes from a single controller or monitor node using a simple programming language. Ansible allows you to automate everything from code deployment to network configuration to cloud management, using SSH, in a human-readable language, with no agents to install on remote systems. Ansible offers open-source automation that is simple, flexible, and powerful, capable of configuring systems, deploying software, and orchestrating more advanced IT tasks such as continuous deployments or zero downtime rolling updates.

Here's why Red Hat Ansible Automation Platform is a game-changer:

  • Relevance to all sizes of environments, catering to diverse users such as developers, sysadmins, release engineers, IT managers, and others.
  • Applicability for managing environments of varying scales, from small setups with a few instances to large enterprise environments with thousands of instances.
  • User-friendly interface, only requiring familiarity with YAML or JSON for efficient operation.
  • Utilization of SSH for device connection and command execution, allowing easy setup of network devices with a few commands and eliminating the need for agent installation. This reduces network maintenance efforts, enhancing network consistency and standardization.

Red Hat Ansible Automation Platform workflow 

Red Hat Ansible Automation Platform Workflow

As illustrated in the diagram, the management node is the controlling node that oversees the entire execution of the Playbook. The inventory file provides the list of hosts where the Ansible modules in the Playbook need to be run (the hosts on which you want to work). The management node establishes an SSH connection, run small modules on the host's machine, installs the software, and removes the modules once installed correctly.

Create a virtual server instance using Automation controller in IBM Power Virtual Server

Now that you are familiar with Red Hat Ansible Automation Platform and its myriad advantages, it is time to create a virtual server instance (VSI) in IBM Cloud.

Prerequisites: 

After successful installation of the Ansible controller, you should be able to see the controller UI screen.  Access the controller using the provided URL and admin password. In this case admin is the default username.

For more information, refer to Red Hat Ansible Automation Platform Release Notes on redhat.com

Now that you have Red Hat Ansible Automation Platform operator with Automation controller in place, let us proceed create a VSI using following steps. 

Step 1. Install IBM Cloud Collection

IBM Cloud Collection must be installed to use Automation controller. Follow these steps to install it:

  1. Clone your forked repo from ‘https://github.com/IBM-Cloud/ansible-collection-ibm.git’ for necessary customizations.
  2. Navigate to ibm-cloudcollection/ansible-collection-ibm/examples/simple-vm-power-vs in your forked repo.
  3. Create a ‘collections’ folder in your project root path and create ‘requirements.yaml' file with the following content.
    (This installs ibmcloud collection in the controller).
              
             ---
                          collections:
         - name: ibm.cloudcollection
    
  4. In the controller UI, navigate to Settings à Jobs à Details and ensure Enable Collection(s) Download is On
  5. Open ‘create.yaml’ file in GitHub, located at ibm-cloudcollection/ansible-collection-ibm/examples/simple-vm-power-vs. Here is how your ‘create.yaml’ might appear.
    create_yaml_file
  6. Edit the ‘create.yaml’ file focusing on the following fields:
    • pi_image: The image name from Power Virtual Server account. You can get it from boot images section.
    • Pi_cloud_instance_id: Power image cloud instance id.
    • ssh_public_key: Your SSH public key to access virtual machine.
    • IC_REGION: Region where you want to create VSI.
    • IC_ZONE: mention zone where you want to create VSI.

    You can find these details from IBM cloud UI (workspace details), also lookout the configuration page for parameters details such as sys_type, memory etc.  

    Commit changes to your fork repo.  

For more information, refer to IBM Cloud Ansible Collections.

Step 2. Set the API key in the controller

Add a new credential type for the IBM Cloud API key in Automation controller UI.

Navigate to Automation Controller UI à Administration à Credential Type à Add.  

Add API Key

 
The newly added credential type will be available in the credential drop down.  

Create new credential

  
API key is now successfully integrated in the controller. 

Step 3. Add Controller host in default inventory and organization  

Use the default organization and inventory for this purpose and add your host to run the collection. To add host machine, navigate to Automation Controller UI à  Hosts à  Add.

Create new host

Step 4. Create a project

Create a new project by navigating to Automation Controller UI à Resources à Projects.

Provide your forked IBM Cloud Collection GitHub/GitLab repo path containing your playbooks in the Source Controller URL field.  
E.g., https://github.com/ashwinik30/ansible-collection-ibm.

Provide all other required details and click Save.

Create new project

After a successful sync, proceed to the next step.

Note: Sync your project whenever changes are made in your forked repo, to get latest commit.  

Step 5. Add a template to run job

Navigate to Automation Controller UI à Templates to add a new template. 

Create new job templates

Specify the details as shown.

From the list of Playbook, select your Playbook.

At this step, your project, organization, inventory, credential etc., are configured in one place. After configuration, click Launch to run your job. 

To view the output, navigate to Automation Controller UI à Views à Jobs à Output.

Following is the sample output, containing the stage public IP address for the external IP.  

Sample output

 

Sample output 2

The Virtual server instance is successfully created in your IBM cloud workspace.

Sample output 3

 
Use your external IP to connect to your node with provided key (public key to add and private key to access the node).  
 
Use the following command to view VM: 

 ssh root@External_ip_addess -i  /path_to/your_private_key  

Summary

That brings us to the end of this blog! We hope you are feeling more confident now that you've learned how to install Red Hat Ansible Automation Platform on OpenShift Container Platform on Power. You can now try your hand at starting a sample controller UI and running some sample program such as hello_world.yaml playbook to say hello to Ansible. With Ansible the options are infinite, and there is always something more to explore. We would like to know how you are using this solution, so drop us a comment. 

Permalink