The vmware_guest module

This module allows you to launch and manage virtual machines within your VMware cluster; the following example shows how you would launch a VM using a template:

- name: Create a VM from a template
vmware_guest:
hostname: "{{ vsphere_host }}"
username: "{{ vsphere_username }}"
password: "{{ vsphere_password }}"
validate_certs: "no"
datacenter: "my-datacenter"
folder: "/vms"
name: "yet_another_example_vm"
state: "poweredon"
template: "centos7-x86_64-1804"
disk:
- size_gb: "40"
type: "thin"
datastore: "my_datastore"
hardware:
memory_mb: "4048"
num_cpus: "4"
max_connections: "3"
hotadd_cpu: "True"
hotremove_cpu: "True"
hotadd_memory: "True"
networks:
- name: "VM Network"
ip: "192.168.1.100"
netmask: "255.255.255.0"
gateway: "192.168.1.254"
dns_servers:
- "192.168.1.1"
- "192.168.1.2"
wait_for_ip_address: "yes"
delegate_to: "localhost"
register: deploy

As you can see, we have quite a lot of control over the VM and how it is configured. There are separate sections for the hardware, network, and storage configuration; we will look at this module in a little more detail at the end of this chapter.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.222.179.186