• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer

Mister PKI

SSL Certificates * SSL Tools * Certificate Decoder

  • Buy SSL Certificates
  • Blog
  • OpenSSL
  • Keytool
  • SSL Tools
  • Donate

Ansible Create VM VMware

February 22, 2023 by Mister PKI Leave a Comment

This article will demonstrate how to use Ansible to create a VM in VMware. Ansible can be used to automate the provisioning of new virtual machines in a VMware environment. This article will focus on how to utilize an already built VMware template, specifically a Redhat 9 template.

The examples in this article assume a working ansible installation, a working VMware environment, and an already built RHEL 9 template. For the examples in this article, ansible is installed and running on an Ubuntu server.

Install python dependencies

The Pyvmomi python module is required. To install the Pyvmomi module run the following series of commands. Sudo privileges are required.

  1. Update and upgrade your OS.
apt update
apt -y upgrade 
  1. Check your python version and pip version. If pip is not installed, install it.
python3 -V
apt install -y python3-pip
  1. Install the Pyvmomi python module with pip3.
pip3 install Pyvmomi

Create Ansible Playbook for VMware VM

The username and password in this example are assumed to be administrator credentials in your environment.

A few properties in the above playbook are worthy of explanation.

  • validate_certs: False – If you have a valid certificate installed in your vcenter, this can be removed. Because most vcenter installations are on a private network, many times the certificate isn’t trusted.
  • template: This is the template you are using to deploy a new VM from. Note that this template name should be unique in your vcenter environment.
  • datacenter: The datacenter name in vcenter where your VM will be located.
  • folder: The folder structure and location of your new VM.
  • wait_for_ip_address: true – This will increase the clone time as it will wait until the VM has an IP address, but after completion you will be ready to ssh into the new Virtual Machine.

If you encounter any issues you can check the following potential problems:

  • Correct credentials and permissions
  • Datacenter is named correctly
  • Template exists and has a unique name
  • Ensure the folder exists

VMware template creation

This section is not an exhaustive set of instructions for creating a new Redhat template in VMware. But if you have not already created one, here are a few notes to get you started.

  1. Download the Boot ISO from your Redhat support panel.
  2. Upload the ISO to your Datastore ISO files in VMware vcenter. If the upload fails it may be because the web server certificate is not trusted. If that’s the case, explicitly trust it and try again.
  3. Create the new Redhat template with the uploaded ISO.

Conclusion – Ansible Create VM VMware

This article has demonstrated how to use Ansible to create a VM in VMware. Leave us a comment if you have any questions or would like to see further examples of provisioning new VMs in VMware with Ansible. If you found this article helpful, please read more of our content.

ansible,  linux,  redhat

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

Popular Posts

PKCS12

openssl s_client

Keytool

Keytool list

ECDSA vs RSA

OpenSSL

PKCS7

Certificate Decoder

Training Courses

Top online courses in IT & Software

Cyber Security Training

Udemy - The Complete Internet Security Privacy Course icon

Buy SSL Certificates

The SSL Store

Comodo Store

Sectigo Store

RapidSSL

Recent Posts

  • Ansible Create VM VMware
  • Perl send email windows
  • DNS Powershell
  • httpd SELinux
  • What is netstat command?

Footer

  • Twitter
  • YouTube

Pages

  • About Mister PKI
  • Blog
  • Compare and Buy Affordable PKI Certificates
  • Contact Us
  • Full Disclosure
  • Privacy Policy
  • SSL Tools – Certificate Decoder and Certificate Checker

Copyright © 2023