SathiyarajPeriyannan.vsphere
ansible-role-vsphere
This Ansible role helps create virtual machines in a VMware environment. It updates the IP addresses of the virtual machines in the inventory file so they can be used later in other roles or playbooks.
Requirements
- You need to have the
pysphere
package installed on your Ansible machine. - Your VMware vCenter environment must be set up and accessible.
- A template version of the virtual machine must be available in vCenter for deployment.
Role Variables
Here’s a list of available variables:
vsphere_vcenter_hostname
: "vcenter1"
This is the name or IP address of the vCenter server.vsphere_vcenter_username
: "root"
The username to log in to the vCenter server.vsphere_vcenter_password
: "passwd"
The password for the username to connect to the vCenter server.vsphere_datacenter_name
: "datacenter1"
The datacenter where the virtual machines will be created.vsphere_esxi_host
: "esx1"
The ESXi server where the virtual machines will be associated.vsphere_datastore_name
: "datastore1"
The name of the datastore where the virtual machine's hard disk will be stored.vsphere_template_name
: "centos_template"
The pre-installed OS template that will be used for installation.
In the inventory file, the host variables are listed below with default values:
[hosts]
This is the group name that collects the list of virtual machine names in the inventory file.<vm name> cpu=2 memory=4096 disk=20
Here, replace<vm name>
with the name of your virtual machine, followed by the number of virtual CPUs required, memory size in MB, and disk size in GB.
Dependencies
- None
Example Playbook
Here’s an example playbook to use this role:
- hosts: hosts
connection: local
vars:
vsphere_vcenter_hostname: "vcenter1"
vsphere_vcenter_username: "root"
vsphere_vcenter_password: "passwd"
vsphere_datacenter_name: "datacenter1"
vsphere_esxi_host: "esx1"
vsphere_datastore_name: "datastore1"
vsphere_template_name: "centos_template"
roles:
- SathiyarajPeriyannan.vsphere
License
- BSD
Author Information
This role was created in 2016 by Sathiyaraj Periyannan.
Virtual Machine creation in vCenter environment
ansible-galaxy install SathiyarajPeriyannan.vsphere