vmware.vmware.folder_template_from_vm module – Create a template in a local VCenter folder from an existing VM
Note
This module is part of the vmware.vmware collection (version 1.7.1).
You might already have this collection installed if you are using the ansible
package.
It is not included in ansible-core
.
To check whether it is installed, run ansible-galaxy collection list
.
To install it, use: ansible-galaxy collection install vmware.vmware
.
You need further requirements to be able to use this module,
see Requirements for details.
To use it in a playbook, specify: vmware.vmware.folder_template_from_vm
.
Synopsis
This module creates a template in a local VCenter folder from an existing VM. The folder must already exist. The VM must be powered off, and is otherwise unchanged. If the template already exists and the desired state is ‘present’, nothing is done.
Requirements
The below requirements are needed on the host that executes this module.
pyvmomi
Parameters
Parameter |
Comments |
---|---|
The cluster to use when connecting to a vCenter. |
|
The name of datacenter in which to operate |
|
The name of datastore to use as storage for the template. |
|
The hostname or IP address of the vSphere vCenter server. If the value is not specified in the task, the value of environment variable |
|
The password of the vSphere vCenter server. If the value is not specified in the task, the value of environment variable |
|
The port number of the vSphere vCenter server. If the value is not specified in the task, the value of environment variable Default: |
|
Address of a proxy that will receive all HTTPS requests and relay them. The format is a hostname or a IP. If the value is not specified in the task, the value of environment variable |
|
Port of the HTTP proxy that will receive all HTTPS requests and relay them. If the value is not specified in the task, the value of environment variable |
|
The resource pool to place the template in. |
|
If the template should be present or absent Choices:
|
|
The name of the folder that the new template should be placed in Should be the full folder path, with or without the ‘datacenter/vm/’ prefix For example ‘datacenter name/vm/path/to/folder’ or ‘path/to/folder’ |
|
The name to give to the new template. |
|
The username of the vSphere vCenter server. If the value is not specified in the task, the value of environment variable |
|
Allows connection when SSL certificates are not valid. Set to If the value is not specified in the task, the value of environment variable Choices:
|
|
The MOID of the vm to be used to create the template One of vm_name, vm_moid, vm_uuid is required This parameter is ignored when state is ‘absent’ |
|
The name of the vm to be used to create the template One of vm_name, vm_moid, vm_uuid is required This parameter is ignored when state is ‘absent’ |
|
If using vm_name and multiple VMs have the same name, specify which VM should be selected Choices:
|
|
If true, search by instance UUID instead of BIOS UUID. BIOS UUID may not be unique and may cause errors. Choices:
|
|
The UUID of the vm to be used to create the template One of vm_name, vm_moid, vm_uuid is required This parameter is ignored when state is ‘absent’ |
|
If true, the module will wait until the template is created to exit. Choices:
|
Attributes
Attribute |
Support |
Description |
---|---|---|
Support: full |
The check_mode support. |
Notes
Note
All modules require API write access and hence is not supported on a free ESXi license.
Examples
- name: Create A New Template Using VM UUID
vmware.vmware.folder_template:
hostname: "https://vcenter"
username: "username"
password: "password"
datacenter: "my-datacenter"
vm_uuid: "11111111-11111111-11111111"
template_folder: "my-datacenter/vm/netsted/folder/path/templates"
template_name: "my_template"
- name: Create A New Template Using VM Name
vmware.vmware.folder_template_from_vm:
hostname: "https://vcenter"
username: "username"
password: "password"
datacenter: "my-datacenter"
vm_name: "my_vm"
vm_name_match: "first"
template_name: "my_template"
template_folder: "nested/folder/path/templates"
- name: Destroy A Template In A Folder
vmware.vmware.folder_template_from_vm:
hostname: "https://vcenter"
username: "username"
password: "password"
datacenter: "my-datacenter"
vm_name: "foo"
state: "absent"
template_name: "my_template"
template_folder: "nested/folder/path/templates"