Skip to main content
Redhat Developers  Logo
  • Products

    Featured

    • Red Hat Enterprise Linux
      Red Hat Enterprise Linux Icon
    • Red Hat OpenShift AI
      Red Hat OpenShift AI
    • Red Hat Enterprise Linux AI
      Linux icon inside of a brain
    • Image mode for Red Hat Enterprise Linux
      RHEL image mode
    • Red Hat OpenShift
      Openshift icon
    • Red Hat Ansible Automation Platform
      Ansible icon
    • Red Hat Developer Hub
      Developer Hub
    • View All Red Hat Products
    • Linux

      • Red Hat Enterprise Linux
      • Image mode for Red Hat Enterprise Linux
      • Red Hat Universal Base Images (UBI)
    • Java runtimes & frameworks

      • JBoss Enterprise Application Platform
      • Red Hat build of OpenJDK
    • Kubernetes

      • Red Hat OpenShift
      • Microsoft Azure Red Hat OpenShift
      • Red Hat OpenShift Virtualization
      • Red Hat OpenShift Lightspeed
    • Integration & App Connectivity

      • Red Hat Build of Apache Camel
      • Red Hat Service Interconnect
      • Red Hat Connectivity Link
    • AI/ML

      • Red Hat OpenShift AI
      • Red Hat Enterprise Linux AI
    • Automation

      • Red Hat Ansible Automation Platform
      • Red Hat Ansible Lightspeed
    • Developer tools

      • Red Hat Trusted Software Supply Chain
      • Podman Desktop
      • Red Hat OpenShift Dev Spaces
    • Developer Sandbox

      Developer Sandbox
      Try Red Hat products and technologies without setup or configuration fees for 30 days with this shared Openshift and Kubernetes cluster.
    • Try at no cost
  • Technologies

    Featured

    • AI/ML
      AI/ML Icon
    • Linux
      Linux Icon
    • Kubernetes
      Cloud icon
    • Automation
      Automation Icon showing arrows moving in a circle around a gear
    • View All Technologies
    • Programming Languages & Frameworks

      • Java
      • Python
      • JavaScript
    • System Design & Architecture

      • Red Hat architecture and design patterns
      • Microservices
      • Event-Driven Architecture
      • Databases
    • Developer Productivity

      • Developer productivity
      • Developer Tools
      • GitOps
    • Secure Development & Architectures

      • Security
      • Secure coding
    • Platform Engineering

      • DevOps
      • DevSecOps
      • Ansible automation for applications and services
    • Automated Data Processing

      • AI/ML
      • Data Science
      • Apache Kafka on Kubernetes
      • View All Technologies
    • Start exploring in the Developer Sandbox for free

      sandbox graphic
      Try Red Hat's products and technologies without setup or configuration.
    • Try at no cost
  • Learn

    Featured

    • Kubernetes & Cloud Native
      Openshift icon
    • Linux
      Rhel icon
    • Automation
      Ansible cloud icon
    • Java
      Java icon
    • AI/ML
      AI/ML Icon
    • View All Learning Resources

    E-Books

    • GitOps Cookbook
    • Podman in Action
    • Kubernetes Operators
    • The Path to GitOps
    • View All E-books

    Cheat Sheets

    • Linux Commands
    • Bash Commands
    • Git
    • systemd Commands
    • View All Cheat Sheets

    Documentation

    • API Catalog
    • Product Documentation
    • Legacy Documentation
    • Red Hat Learning

      Learning image
      Boost your technical skills to expert-level with the help of interactive lessons offered by various Red Hat Learning programs.
    • Explore Red Hat Learning
  • Developer Sandbox

    Developer Sandbox

    • Access Red Hat’s products and technologies without setup or configuration, and start developing quicker than ever before with our new, no-cost sandbox environments.
    • Explore Developer Sandbox

    Featured Developer Sandbox activities

    • Get started with your Developer Sandbox
    • OpenShift virtualization and application modernization using the Developer Sandbox
    • Explore all Developer Sandbox activities

    Ready to start developing apps?

    • Try at no cost
  • Blog
  • Events
  • Videos

How to use Ansible to create a VM on Azure via workflow

June 15, 2023
Deepankar Jain
Related topics:
Automation and management
Related products:
Red Hat Ansible Automation PlatformRed Hat Ansible Automation Platform on Microsoft Azure

Share:

    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).
    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 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

    Related Posts

    • Git best practices: Workflows for GitOps deployments

    • How OpenShift Serverless Logic evolved to improve workflows

    • Understanding Ansible Tower Isolated Nodes

    • Customizing an OpenShift Ansible Playbook Bundle

    Recent Posts

    • Alternatives to creating bootc images from scratch

    • How to update OpenStack Services on OpenShift

    • How to integrate vLLM inference into your macOS and iOS apps

    • How Insights events enhance system life cycle management

    • Meet the Red Hat Node.js team at PowerUP 2025

    What’s up next?

    GitOps has become a standard in deploying applications to Kubernetes, and many companies are adopting the methodology for their DevOps and cloud-native strategy. Download the GitOps Cookbook for useful recipes and examples for successful hands-on applications development and deployment with GitOps.

    Download the GitOps Cookbook
    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    Products

    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform

    Build

    • Developer Sandbox
    • Developer Tools
    • Interactive Tutorials
    • API Catalog

    Quicklinks

    • Learning Resources
    • E-books
    • Cheat Sheets
    • Blog
    • Events
    • Newsletter

    Communicate

    • About us
    • Contact sales
    • Find a partner
    • Report a website issue
    • Site Status Dashboard
    • Report a security problem

    RED HAT DEVELOPER

    Build here. Go anywhere.

    We serve the builders. The problem solvers who create careers with code.

    Join us if you’re a developer, software engineer, web designer, front-end designer, UX designer, computer scientist, architect, tester, product manager, project manager or team lead.

    Sign me up

    Red Hat legal and privacy links

    • About Red Hat
    • Jobs
    • Events
    • Locations
    • Contact Red Hat
    • Red Hat Blog
    • Inclusion at Red Hat
    • Cool Stuff Store
    • Red Hat Summit

    Red Hat legal and privacy links

    • Privacy statement
    • Terms of use
    • All policies and guidelines
    • Digital accessibility

    Report a website issue