ansible share image

In our previous article, we demonstrated how to use the Red Hat Ansible Automation Platform to create a virtual machine (VM) in Microsoft Azure. Ansible Automation Platform streamlines the process of deploying VMs in Azure, making it more efficient and less error-prone.

In this article, we will demonstrate how to simplify the process of creating VMs in Azure by using workflow templates with Ansible Automation Platform. Workflow templates can help standardize the process of creating VMs and reduce the amount of manual intervention required. We will dive into the details for using workflow templates with Ansible Automation Platform to further optimize our infrastructure management in Azure.

If you're following along with this series, you may recall that we previously discussed the importance of creating an execution environment and setting up credentials. These are essential steps that need to be completed before deploying a workflow template. In case you missed it, we recommend you check it out to ensure you're ready to move forward with the next steps.

Follow the series:

Creating and configuring the project

At this point, we assume that you have already set up your execution environment and credentials, so we'll focus on how to deploy a workflow template in Azure using Ansible Automation Platform.

Follow these steps to create and configure the project:

  • Log in to the Ansible Automation Platform Portal in browser.
  • Navigate to the Projects tab under resources and click Add.
  • Provide your project name and choose Git as the source control type.
  • Enter the source control URL: If you're interested in checking out the Ansible Playbooks, you can find them on GitHub.
  • Save your changes and wait for the operation to complete successfully.

When selecting Git as your source control type, the platform pulls down the latest versions of your files for use in Ansible jobs and workflows. This makes it easy to manage changes, collaborate with others, and track configuration history over time.

Creating and configuring the job templates

  • Go to the Templates tab and click Add.
  • Select Job template.
  • Name your job and select the default or Demo-Inventory under Inventory.
  • Under Project, select the project name you created earlier and choose the Azure/Workflow/01_create_rg.yml playbook file.
  • Choose the credentials you previously created (Figure 1).
A screenshot of the page to select pre-configured Azure credentials.
Figure 1: Selecting pre-configured Azure credentials for secure authentication.

Choose the execution environment you previously created (Figure 2).

Figure 2: Selecting pre-configured execution environment
Figure 2: Select the pre-configured execution environment.
  • Repeat the previous steps for any other playbooks in the Azure/Workflow/ directory.

Creating and configuring the workflow templates

  • Create a workflow template and assign a name to it, as shown in Figure 3.
A screenshot of the create a workflow template page in Ansible.
Figure 3: Create a workflow template.
  • In the Variables section, add the following variables:

vm_name: "Test-Ansible"

vm_size: "Standard_B1ls"

vm_image: "RedHat:RHEL:8-LVM:latest"

vm_username: "testansible"

vm_password: "my-password@1234"

rg_name: "test-ansible"

vnet_name: "test-ansible"

subnet_name: "test-ansible"

location: "centralindia"

offer: “CentOS”

publisher: “OpenLogic”

sku: “7.5”

version: ”latest”
  • Save the workflow before proceeding and visualize the workflow when prompted (Figure 4).
A screenshot of selecting the job templates as nodes in Ansible workflow.
Figure 4: Selecting the job templates as nodes in workflow.
  • Once you have confirmed the workflow, add each job template to its respective node (Figure 5).
Figure 5: Final workflow visualizer nodes
Figure 5: The final workflow visualizer nodes.
  • After you have added all job templates, launch the workflow to execute it.

Once the workflow is executed, the VM will be up and running, ready for you to use, as seen in Figure 6. This streamlined process ensures that the VM is created quickly and efficiently, saving you valuable time and effort while helping different teams analyze the possible points of failure.

A screenshot of the details page for the virtual machine in Azure.
Figure 6: The details for the virtual machine in Azure. 

Ansible simplifies VM deployment in Azure

This article demonstrated how Ansible Automation Platform can streamline the process of deploying VMs in Azure via workflow. Get started with Ansible Automation Platform by exploring interactive hands-on labs. Download Ansible Automation Platform at no cost and begin your automation journey. You can refer to An IT executive's guide to automationAutomation at the edge, and Choosing an Automation Tool e-books for better understanding of Ansible Automation Platform. A cheat sheet is also available for WiFi automation with Ansible and SD that provides a quick reference for network automation tasks.

We hope this series has provided a solid foundation for exploring the potential of Ansible Automation Platform in your own environment. As you continue to learn and experiment with cloud infrastructure management, remember to stay up to date with the latest trends and techniques by exploring articles and free interactive labs at Red Hat Developer.

Thank you for following our series. Happy automating!

Last updated: January 11, 2024