- AnsibleFest
- Products
- Community
- Webinars & Training
- Blog

Documentation

# vmware_content_deploy_template – Deploy Virtual Machine from template stored in content library

New in version 2.9.

- Synopsis
- Requirements
- Parameters
- Notes
- Examples
- Return Values
- Status

## Synopsis

- Module to deploy virtual machine from template in content library.
- Content Library feature is introduced in vSphere 6.0 version, so this module is not supported in the earlier versions of vSphere.
- All variables and VMware object names are case sensitive.

## Requirements

The below requirements are needed on the host that executes this module.

- python >= 2.6
- PyVmomi
- vSphere Automation SDK

## Parameters

Parameter | Choices/Defaults | Comments
--- | --- | ---
cluster string |  | Name of the cluster in datacenter in which to place deployed VM.
datacenter string / required |  | Name of the datacenter, where VM to be deployed.
datastore string / required |  | Name of the datastore to store deployed VM and disk.
folder string / required |  | Name of the folder in datacenter in which to place deployed VM.
host string / required |  | Name of the ESX Host in datacenter in which to place deployed VM.
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.
name string / required |  | The name of the VM to be deployed. aliases: vm_name
password 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. aliases: pass, pwd
protocol string | Choices: http https ← | The connection to protocol.
resource_pool string |  | Name of the resourcepool in datacenter in which to place deployed VM.
state string | Choices: present ← poweredon | The state of Virtual Machine deployed from template in content library. If set to `present` and VM does not exists, then VM is created. If set to `present` and VM exists, no action is taken. If set to `poweredon` and VM does not exists, then VM is created with powered on state. If set to `poweredon` and VM exists, no action is taken.
template string / required |  | The name of template from which VM to be deployed. aliases: template_src
username 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. aliases: admin, user
validate_certs boolean | Choices: no yes ← | Allows connection when SSL certificates are not valid. Set to `no` 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.

## Notes

Note

- Tested on vSphere 6.7 U3

## Examples

    - name: Deploy Virtual Machine from template in content library
      vmware_content_deploy_template:
        hostname: '{{ vcenter_hostname }}'
        username: '{{ vcenter_username }}'
        password: '{{ vcenter_password }}'
        template: rhel_test_template
        datastore: Shared_NFS_Volume
        folder: vm
        datacenter: Sample_DC_1
        name: Sample_VM
        resource_pool: test_rp
        validate_certs: False
        state: present
      delegate_to: localhost

    - name: Deploy Virtual Machine from template in content library with PowerON State
      vmware_content_deploy_template:
        hostname: '{{ vcenter_hostname }}'
        username: '{{ vcenter_username }}'
        password: '{{ vcenter_password }}'
        template: rhel_test_template
        datastore: Shared_NFS_Volume
        folder: vm
        datacenter: Sample_DC_1
        name: Sample_VM
        resource_pool: test_rp
        validate_certs: False
        state: poweredon
      delegate_to: localhost

## Return Values

Common return values are documented here, the following are the fields unique to this module:

Key | Returned | Description
--- | --- | ---
vm_deploy_info dictionary | on success | Virtual machine deployment message and vm_id Sample: {'msg': "Deployed Virtual Machine 'Sample_VM'.", 'vm_id': 'vm-1009'}

## Status

- This module is not guaranteed to have a backwards compatible interface. [preview]
- This module is maintained by the Ansible Community. [community]

### Authors

- Pavan Bidkar (@pgbidkar)

Hint

If you notice any issues in this documentation, you can edit this document to improve it.