Join AnsibleFest at Red Hat Summit!

vmware.vmware.deploy_folder_template module – Deploy a VM from a template located in a folder

Note

This module is part of the vmware.vmware collection (version 1.10.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.

To use it in a playbook, specify: vmware.vmware.deploy_folder_template.

Synopsis

  • Create a VM from a template that is located in vCenter. The template must be found in a folder, as opposed to being in a content library.

  • This module manages the deployed VM, not the template. The template will be unchanged.

  • To further configure the VM, ensure it is deployed in the powered off state and then use other modules to configure it.

  • The module basis idempotentency on if the deployed VM exists or not, not the storage or power settings applied at deployment time.

Parameters

Parameter

Comments

cluster

aliases: cluster_name

string

The name of the cluster where the VM should be deployed.

Changing this option will not result in the VM being redeployed (it does not affect idempotency).

resource_pool and cluster are mutually exclusive.

datacenter

aliases: datacenter_name

string / required

The name of the datacenter to use when searching for and deploying resources.

datastore

string

Name of the datastore to store deployed VM and disk.

datastore and datastore_cluster are mutually exclusive.

datastore_cluster

string

Name of the datastore cluster to store deployed VM and disk.

Please make sure Storage DRS is active for recommended datastore from the given datastore cluster.

If Storage DRS is not enabled, datastore with largest free storage space is selected.

datastore and datastore_cluster are mutually exclusive.

esxi_host

aliases: host

string

The name of the ESXi host onto which the virtual machine should be deployed.

If esxi_host and resource_pool are both specified, resource_pool must belong to esxi_host.

If esxi_host and cluster are both specified, esxi_host must be a member of cluster.

Changing this option will not result in the VM being redeployed (it does not affect idempotency).

hostname

string

The hostname or IP address of the vSphere vCenter server.

If the value is not specified in the task, the value of environment variable VMWARE_HOST will be used instead.

password

aliases: pass, pwd

string

The password of the vSphere vCenter server.

If the value is not specified in the task, the value of environment variable VMWARE_PASSWORD will be used instead.

port

integer

The port number of the vSphere vCenter server.

If the value is not specified in the task, the value of environment variable VMWARE_PORT will be used instead.

Default: 443

power_on_after_deploy

boolean

Whether or not the VM should be powered on once it has been deployed.

This is only applied when the VM is deployed. If the VM already exists, the power state is not modified.

Changing this option will not result in the VM being redeployed (it does not affect idempotency).

Choices:

  • false ← (default)

  • true

proxy_host

string

The 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 VMWARE_PROXY_HOST will be used instead.

proxy_port

integer

The 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 VMWARE_PROXY_PORT will be used instead.

resource_pool

string

The name of a resource pool into which the virtual machine should be deployed.

Changing this option will not result in the VM being redeployed (it does not affect idempotency).

resource_pool and cluster are mutually exclusive.

template_folder

string

The path to the folder where the template with template_name exists.

This parameter is not used if template_id is supplied.

This can be an absolute (/datacenter/vm/my/folder) or relative (my/folder) path.

This parameter is mutually exclusive with template_folder_id.

template_folder_id

string

The ID of the folder where the template with template_name exists.

This parameter is not used if template_id is supplied.

This parameter is mutually exclusive with template_folder.

template_id

string

The ID of the template to use when deploying.

This parameter takes precedence over template_name and template_folder

template_name

string

The name of the template to use when deploying.

You must also supply template_folder if you use this parameter.

This parameter is not used if template_id is supplied.

username

aliases: admin, user

string

The username of the vSphere vCenter server.

If the value is not specified in the task, the value of environment variable VMWARE_USER will be used instead.

validate_certs

boolean

Allows connection when SSL certificates are not valid. Set to false when certificates are not trusted.

If the value is not specified in the task, the value of environment variable VMWARE_VALIDATE_CERTS will be used instead.

Choices:

  • false

  • true ← (default)

vm_folder

aliases: folder

string

Virtual machine folder into which the virtual machine should be deployed.

This can be the absolute folder path, or a relative folder path under /<datacenter>/vm/. See the examples for more info.

This option is required if you have more than one VM with the same name in the datacenter.

Changing this option will result in the VM being redeployed, since it affects where the module looks for the deployed VM.

If not provided, the /<datacenter>/vm/ folder is used.

vm_name

string / required

The name of the VM to deploy.

If you have multiple VMs with the same name, you should also supply vm_folder

Attributes

Attribute

Support

Description

check_mode

Support: full

The check_mode support.

Notes

Note

  • All modules require API write access and hence are not supported on a free ESXi license.

  • All variables and VMware object names are case sensitive.

  • Modules may rely on the ‘requests’ python library, which does not use the system certificate store by default. You can specify the certificate store by setting the REQUESTS_CA_BUNDLE environment variable. Example: ‘export REQUESTS_CA_BUNDLE=/path/to/your/ca_bundle.pem’

See Also

See also

vmware.vmware.folder_template_from_vm

Create a template in a local VCenter folder from an existing VM.

Examples

- name: Create A New VM From A Template
  vmware.vmware.deploy_folder_template:
    hostname: "https://vcenter"
    username: "username"
    password: "password"
    datacenter: "my-datacenter"
    vm_name: "my_vm"
    template_name: "my_template"

- name: Create A New Template Using Folders To Specify Which VM and Template
  vmware.vmware.deploy_folder_template:
    hostname: "https://vcenter"
    username: "username"
    password: "password"
    datacenter: "my-datacenter"
    vm_name: "my_vm"
    template_name: "my_template"
    vm_folder: foo/bar/my/vms
    template_folder: /my-datacenter/vm/foo/bar/my/templates

Authors

  • Ansible Cloud Team (@ansible-collections)