-
Notifications
You must be signed in to change notification settings - Fork 5
Resource vsphere_vapp
Shankar Ram Nagarajan edited this page Jun 23, 2017
·
5 revisions
This resource can be used to create and delete vApp in vSphere environment. Creation of vApp happens by cloning an existing vApp or create a new vApp from scratch. Addition of entities (VMs and child vApps) can be done later or during creation of vApp too.
resource "vsphere_vapp" <"vApp resource name"> {
name = <"New vApp name">
description = <"Description of this new vApp">
datacenter = <"Datacenter name">
cluster = <"Cluster name">
folder = <"Folder name">
datastore = <"Datastore name">
resource_pool = <"Resource pool name">
parent_vapp = <"parent vApp name">
uuid = <"UUID of newly created vApp">
template_vapp {
name = <"vApp to be cloned">
disk_provisioning = <"Disk provisioning format">
network_mapping {
source_network_label = <"Source Network label">
destination_network_label =<"Destination Network label">
}
}
entity {
name = <"VM/vApp to be moved into">
folder = <"Path of the entity">
type = <"Entity type">
start_order = <"Start order of the entity">
start_delay = <"Start delay">
start_action = <"Start action while powering on the vApp">
stop_action = <"Stop action while powering off the vApp">
stop_delay = <"Stop delay">
folder_path = <"Original inventory path of the entity">
moid = <"Managed Object ID of the entity">
resourcepool_path = <"Original resource pool of the entity">
}
}
Note:
- In update operation, only entity addition / deletion is supported. Entity properties also can be updated.
- Update operation is not applicable for vApp entities which came via cloning.
- Terraform created VMs that are to be moved into a vApp must be created and managed by separate templates and state files.
- VMs are moved out to their original folder/resource-pool while destroying vApp. However, if they come through cloning, all VMs are deleted along with the vApp.
- vApp to be cloned should be in powerOff state.
- name - (Mandatory) Name of the vApp which is being created.
- description - (Optional) Description of the new vApp.
- datacenter - (Optional) Name of the Datacenter in which to launch the vApp.
- cluster - (Optional) Name of the Cluster in which to launch the vApp.
- folder - (Optional) Name of the Folder under which vApp is created.
- datastore - (Optional) Datastore for all the VMs disk.
- resource_pool - (Optional) Name of the Resource Pool in which to launch the vApp.
- parent_vapp - (Optional) Name of the vApp under which new vApp is created.
- uuid - (Computed) UUID of the newly created vApp.
- template_vapp - (Optional) Configures source vApp template properties.
- entity - (Optional) Configures entity properties. List of entities can be configured.
The template_vapp
block supports
- name - (Mandatory) Name of the source vApp/Template.
-
disk_provisioning - (Optional) Disk format to store the virtual machine's virtual disk. Supported values:
sameAsSource
,thick
,thin
. Default value:sameAsSource
. - network_mapping - (Optional) Configures list of network mapping for cloning.
The template_vapp/network_mapping
block supports
- source_network_label - (Mandatory) Name of network in origin vApp.
- destination_network_label - (Mandatory) Name of network in new vApp.
The entity
block supports
- name - (Mandatory) Name of the VM/vApp to be moved in.
-
type - (Mandatory) Type of the entity. Supported values:
vm
andvapp
. - folder - (Optional) Folder path of the entity to be moved.
- start_order - (Optional) Specifies the start order for this entity. Entities are started from lower numbers to higher-numbers and reverse on shutdown. Value must be 0 or higher.
- start_delay - (Optional) Delay in seconds before continuing with the next entity in the order of entities to be started.
-
start_action - (Optional) Specifies how to start the entity. Supported values:
none
andpowerOn
. -
stop_action - (Optional) Specifies how to stop the entity. Supported values:
none
,powerOff
,guestShutdown
andsuspend
. - stop_delay - (Optional) Delay in seconds before continuing with the next entity in the order sequence. This is only used if the stopAction is guestShutdown.
- folder_path - (Computed) Original inventory path of the entity before move-in.
- resourcepool_path - (Computed) Original resource pool of the entity before move-in.
- moid - (Computed) Managed Object ID of the entity.
Clone a vApp under the given Resource Pool and Folder
resource "vsphere_vapp" "vAppRP" {
name = "cloned-vapp-under-resourse-pool"
description = "Cloning vApp under a resource pool from Terraform"
datacenter = "DC Networking"
folder = "terraform/vapp"
datastore = "datastore1"
resource_pool = "terraform_pool"
template_vapp {
name = "test-vapp-1"
}
}
Clone a vApp under the given Cluster
resource "vsphere_vapp" "vAppCluster" {
name = "cloned-vapp-under-cluster"
description = "Cloning vApp under a Cluster from Terraform"
datacenter = "DC Networking"
folder = "terraform/vapp"
datastore = "datastore1"
cluster = "vmware-vapp-2"
template_vapp {
name = "test-vapp-1"
network_mapping {
source_network_label = "external-net-410"
destination_network_label = "external-net-411"
}
}
}
Clone a vApp under a vApp with full path
resource "vsphere_vapp" "vAppNested" {
name = "cloned-vapp-under-full-path-vapp"
description = "Cloning vApp from Terraform"
datacenter = "DC Networking"
datastore = "datastore1"
parent_vapp = "terraform/vapp/parent-vapp"
template_vapp {
name = "test-vapp-1"
disk_provisioning = "thick"
}
}
Create a vApp with pre-created VMs
resource "vsphere_vapp" "vAppWithVMs" {
name = "create-vapp-with-VMs"
datacenter = "DC Networking"
entity {
name = "web_server"
type = "vm"
}
entity {
name = "database"
type = "vm"
}
}
Clone a vApp from template vApp and add pre-created VMs
resource "vsphere_vapp" "vAppFromTemplateVAppWithVMs" {
name = "clone-vapp-and-add-VMs"
datacenter = "DC Networking"
datastore = "datastore1"
template_vapp {
name = "test-vapp-1"
}
entity {
name = "web_server"
type = "vm"
}
entity {
name = "database"
type = "vm"
}
}