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 create a GCP instance via workflow and Ansible

July 12, 2023
Deepankar Jain
Related topics:
Automation and management
Related products:
Red Hat Ansible Automation PlatformRed Hat Ansible Automation Platform via Google Cloud Marketplace

Share:

    In our previous article, we explored how to use the Red Hat Ansible Automation Platform to create an instance in Google Compute Engine. We saw how Ansible Automation Platform can streamline the process of deploying instances in GCP, making it more efficient and less error-prone.

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

    If you're following along with our 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 that article, we recommend you to check it out to ensure that you're ready to move forward with the next steps. We'll assume that you have already set up your execution environment and credentials, and we'll focus on how to deploy a workflow template in GCP using Ansible Automation Platform.

    Follow the series:

    Part 1: How to create an instance on GCP using Ansible CLI

    Part 2: How to create a GCP instance using Ansible Automation

    Part 3: How to create a GCP instance via workflow and Ansible

    Creating and configuring the project

    • Log in to the Ansible Automation Platform Portal in a 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 as https://github.com/redhat-developer-demos/ansible-automation-platform-cloud-solutions. If you're interested in checking out the 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", then 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 "GCP/Workflow/01_create_disk.yml" playbook file.
    • Choose the credentials and execution environment you previously created.
    • Figure 1 shows where to select GCP credentials.
    Select GCP credentials.
    Figure 1: Select GCP credentials.

    Figure 2 shows where to select the pre-configured execution environment.

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

    Creating and configuring the workflow templates

    • To start, create a workflow template and assign a name to it (Figure 3).
    Create a workflow template.
    Figure 3: Create a workflow template.
    • In the "Variables" section, add the following variables.
    ---
    
    network_name: "test-ansible-network"
    
    subnet_name: "test-ansible-subnet"
    
    ip_name: "test-ansible-ip"
    
    disk_name: "test-ansible-disk"
    
    machine_name: "test-ansible"
    
    region: "asia-south2"
    
    zone: "asia-south2-a"
    
    source_image: "projects/ubuntu-os-cloud/global/images/family/ubuntu-1804-lts"
    
    subnet_cidr: "10.0.1.0/24"
    
    disk_size: 10
    
    machine_type: "f1-micro"
    • Save the workflow before proceeding and visualize the workflow when prompted (Figure 4).
    Selecting the job templates as nodes in 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).
    • After all job templates have been added, launch the workflow to execute it.
    The final workflow visualizer nodes.
    Figure 5: The final workflow visualizer nodes.

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

    Instance in GCP.
    Figure 6: Instance in GCP.

    Summary

    We demonstrated how Ansible Automation Platform can streamline the process of deploying Instances in GCP. With the ability to automate repetitive tasks, you can reduce manual intervention and avoid human error, leading to faster, more consistent deployments and improved reliability.

    To explore more of what Ansible Automation Platform has to offer, visit the official website to download and get started. You may also explore the Ansible on Azure lab for deploying Ansible Automation Platform on Microsoft Azure and performing automation tasks in your Azure environment. Additionally, there are various e-books available to help you explore the capabilities of Ansible Automation Platform, with Automation at the Edge, Choosing an Automation Tool, and An IT Executive's Guide to Automation. A cheat sheet is also available for WiFi automation with Ansible and SD to provide you with a quick reference for network automation tasks.

    We hope this series has provided a solid foundation to explore 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 blogs and interactive labs at Red Hat Developer.

    Last updated: January 11, 2024

    Related Posts

    • Using Ansible to automate Google Cloud Platform

    • 5 examples of security automation with Ansible

    • Write your own Red Hat Ansible Tower inventory plugin

    • Example of using Ansible to update Container Native Storage

    Recent Posts

    • Create and enrich ServiceNow ITSM tickets with Ansible Automation Platform

    • Expand Model-as-a-Service for secure enterprise AI

    • OpenShift LACP bonding performance expectations

    • Build container images in CI/CD with Tekton and Buildpacks

    • How to deploy OpenShift AI & Service Mesh 3 on one cluster

    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
    © 2025 Red Hat

    Red Hat legal and privacy links

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

    Report a website issue