Top Posts
What’s New In VMware Cloud Foundation 9.0
Deploying & Configuring the VMware LCM Bundle Utility...
VMware Cloud Foundation: Don’t Forget About SSO Service...
VMware Explore Las Vegas 2025: Illuminating the Path...
Securing Software Updates for VMware Cloud Foundation: What...
VMware Cloud Foundation 5.2: A Guide to Simplified...
VMware Cloud Foundation 5.2: Unlocking Secure Hybrid Cloud...
VMware Cloud Foundation – Memory Tiering: Optimizing Memory...
Decoding VMware Cloud Foundation: Unveiling the numerous amount...
VMware Cloud Director 10.6.1: Taking Cloud Management to...
Virtual Bytes
  • Home
  • Home Data Center 2025
  • VMware
    • Cloud
    • Datacenter & Cloud Infrastructure
      • VMware ESXi
      • VMware vCenter
      • VMware vSAN
    • Networking & Security
    • Desktop & App Virtualization
      • Omnissa Horizon
    • Troubleshooting
    • Ansible
  • Education
  • Hardware
    • Hardware Tips & Tricks
  • Events
  • About
    • About Me
    • Home Lab Archives
      • Home Lab 2020-2022
      • Home Lab 2016-2020
Tag:

clones

Ansible

Creating Multiple Virtual Machines with Ansible in VMware vSphere 7 Update 1

by Tommy Grot October 15, 2020
written by Tommy Grot 2 minutes read

In today’s blog post, we will be creating a Ansible Playbook to create multiple Virtual Machines within VMware vSphere 7 Update 1.

These tasks below are completed via Ubuntu 20.04, if you need to download Ubuntu do it here.

My personal recommendation is to have a Virtual Machine with Ubuntu server with Ansible installed to do all this work, if you are not comfortable with Command Line Interface (CLI) you may also use Ubuntu Desktop.

Step 1 – Update / Upgrade your Ubuntu 20.04 Virtual Machine

sudo apt update -y
 sudo apt upgrade -y

If need to reboot then run this command.

sudo reboot 

After rebooting the Virtual Machine, log back in and check to see if you have the latest python installed with this command below

python3 -v

Once Python3 is verified you will need to install python3-pyvmomi, this is a Python SDK for the VMware vSphere API.

apt install python3-pyvmomi

Below is a playbook to create multiple Virtual Machines, prior to running this playbook. You will need to have a template configured and ready!

Few things to do before running this playbook:

  • Create a “[email protected]” account to run all your playbooks, instead of using the [email protected] default account.
  • Have a virtual machine template already converted and ready to be deployed.
  • Fill out all required variables / information of your: vCenter Server IP Address or DNS, username, password, data center name, template name, datastore name.
  • Configure the naming convention you want your Virtual Machines to be named, by configuring the “with_items” below and how many clones you will want to be created.

---
 - hosts: localhost
  gather_facts: no
  vars:
    vcenter_server: "vCenter IP Address or DNS"
    vcenter_user: "[email protected]" 
    vcenter_pass: "Insert_vCenter Password"
    datacenter_name: "Datacenter"
    #cluster_name: "Cluster" uncomment this if you have a cluster
  tasks:
  name: Clone the template 
  vmware_guest:
  hostname: "{{ vcenter_server }}"
  username: "{{ vcenter_user }}"
  password: "{{ vcenter_pass }}"
  validate_certs: False
  name: "{{ item }}"
  template: template-esxi-0
  datacenter: "{{ datacenter_name }}"
  folder: /
  #cluster: "{{ cluster_name }}" uncomment this if you have a cluster
  datastore: "<Insert Datastore Name>" 
  state: poweredon 
 with_items:
  #Configure the amount of Clones you would like with the items below.
  - <your vm name01>
  - <your vm name02>
  - <your vm name03>

October 15, 2020 0 comments 3.9K views
0 FacebookTwitterLinkedinEmail




Recent Posts

  • What’s New In VMware Cloud Foundation 9.0
  • Deploying & Configuring the VMware LCM Bundle Utility on Photon OS: A Step-by-Step Guide
  • VMware Cloud Foundation: Don’t Forget About SSO Service Accounts
  • VMware Explore Las Vegas 2025: Illuminating the Path to Cloud Excellence!
  • Securing Software Updates for VMware Cloud Foundation: What You Need to Know

AI AVI Vantage cloud Cloud Computing cloud director computing configure cyber security director dns domain controller ESXi How To las vegas llm llms multi-cloud multicloud NSx NSX-T 3.2.0 private AI servers ssh storage tenant upgrade vcd vcda VCDX vcenter VCF VDC vexpert Virtual Machines VMs vmware vmware.com vmware aria VMware Cloud Foundation VMware cluster VMware Explore VMware NSX vrslcm vsan walkthrough

  • Twitter
  • Instagram
  • Linkedin
  • Youtube

@2023 - All Right Reserved. Designed and Developed by Virtual Bytes

Virtual Bytes
  • Home
  • Home Data Center 2025
  • VMware
    • Cloud
    • Datacenter & Cloud Infrastructure
      • VMware ESXi
      • VMware vCenter
      • VMware vSAN
    • Networking & Security
    • Desktop & App Virtualization
      • Omnissa Horizon
    • Troubleshooting
    • Ansible
  • Education
  • Hardware
    • Hardware Tips & Tricks
  • Events
  • About
    • About Me
    • Home Lab Archives
      • Home Lab 2020-2022
      • Home Lab 2016-2020