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:
- Part 1: How to automate VM creation on Azure with Ansible CLI
- Part 2: How to use Ansible to create a VM on Azure
- Part 3: How to use Ansible to create a VM on Azure via workflow
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: https://github.com/redhat-developer-demos/ansible-automation-platform-cloud-solutions. 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).
Choose the execution environment you previously created (Figure 2).
- 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.
- 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).
- Once you have confirmed the workflow, add each job template to its respective node (Figure 5).
- 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.
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 automation, Automation 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