Skip to content

Terraform module which manages standalone VM ressources on VMWare Cloud Director.

Notifications You must be signed in to change notification settings

noris-network/terraform-vcd-vm

Repository files navigation

terraform-vcd-vm

Terraform module which manages standalone VM ressources on VMWare Cloud Director.

Requirements

Name Version
terraform >= 1.1.9
vcd >= 3.9.0

Providers

Name Version
vcd 3.9.0

Modules

No modules.

Resources

Name Type
vcd_vm.vm resource
vcd_catalog.catalog data source
vcd_catalog_vapp_template.catalog_vapp_template data source

Inputs

Name Description Type Default Required
name A name for the VM. string n/a yes
storage_profile_name Name of Storage Profile. string n/a yes
vdc_org_name The name of the organization to use. string n/a yes
accept_all_eulas Automatically accept EULA if OVA has it. bool true no
boot_image_id Media URN to mount as boot image. string null no
catalog_name Catalog where the vApp template is found. string null no
computer_name Computer name to assign to this virtual machine. string null no
cpu_cores The number of cores per socket. number null no
cpu_hot_add_enabled True if the virtual machine supports addition of virtual CPUs while powered on. bool false no
cpu_limit The limit (in MHz) for how much of CPU can be consumed on the underlying virtualization infrastructure. -1 value for unlimited. number null no
cpu_priority Pre-determined relative priorities according to which the non-reserved portion of this resource is made available to the virtualized workload. string null no
cpu_reservation The amount of MHz reservation on the underlying virtualization infrastructure. number null no
cpu_shares Custom priority for the resource in MHz. This is a read-only, unless the cpu_priority is 'CUSTOM'. number null no
cpus The number of virtual CPUs to allocate to the VM. Socket count is a result of: virtual logical processors/cores per socket. If cpu_hot_add_enabled is true, then cpus will be increased without VM power off. number null no
customization A block to define for guest customization options. any null no
description The VM description. Note: for VM from Template description is read only. Currently, this field has the description of the OVA used to create the VM. string null no
disks List of disks per virtual machine.
list(object({
name = string
bus_number = number
unit_number = number
}))
[] no
expose_hardware_virtualization Boolean for exposing full CPU virtualization to the guest operating system so that applications that require hardware virtualization can run on virtual machines without binary translation or paravirtualization. Useful for hypervisor nesting provided underlying hardware supports it. bool false no
guest_properties Key value map of guest properties. map(any) null no
hardware_version Virtual Hardware Version (e.g.vmx-14, vmx-13, vmx-12, etc.). Required when creating empty VM. string null no
memory The amount of RAM (in MB) to allocate to the VM. number null no
memory_hot_add_enabled True if the virtual machine supports addition of memory while powered on. bool false no
memory_limit The limit (in MB) for how much of memory can be consumed on the underlying virtualization infrastructure. -1 value for unlimited. number null no
memory_priority Pre-determined relative priorities according to which the non-reserved portion of this resource is made available to the virtualized workload. string null no
memory_reservation The amount of RAM (in MB) reservation on the underlying virtualization infrastructure. number null no
memory_shares Custom priority for the resource in MB. This is a read-only, unless the memory_priority is 'CUSTOM'. number null no
metadata_entry A set of metadata entries to assign. list(map(string)) [] no
network A block to define network interfaces. any [] no
network_dhcp_wait_seconds Optional number of seconds to try and wait for DHCP IP. number null no
os_type Operating System type. Possible values can be found in Os Types. Required when creating empty VM. string null no
override_template_disks A list of disks to override in the vApp template.
list(object({
bus_type = string
size_in_mb = number
bus_number = number
unit_number = number
iops = optional(number)
storage_profile = optional(string)
}))
[] no
placement_policy_id VM placement policy ID. To be used, it needs to be assigned to Org VDC using vcd_org_vdc.vm_placement_policy_ids (and optionally vcd_org_vdc.default_compute_policy_id to make it default). In this case, if the placement policy is not set, it will pick the VDC default on creation. It must be set explicitly if one wants to update it to another policy (the VM requires at least one Compute Policy), and needs to be set to '' to be removed. string null no
power_on A boolean value stating if this VM should be powered on. bool true no
prevent_update_power_off True if the virtual machine supports addition of virtual CPUs while powered on. bool false no
security_tags Set of security tags to be managed by the vcd_vapp_vm resource. set(string) null no
sizing_policy_id (vCD 10.0+) VM sizing policy ID. To be used, it needs to be assigned to Org VDC using vcd_org_vdc.vm_sizing_policy_ids (and vcd_org_vdc.default_compute_policy_id to make it default). In this case, if the sizing policy is not set, it will pick the VDC default on creation. It must be set explicitly if one wants to update it to another policy (the VM requires at least one Compute Policy), and needs to be set to '' to be removed. string null no
vapp_template_name vApp template for this maschine. string null no
vdc_name The name of VDC to use. string null no
vm_name_in_template The name of the VM in vApp Template to use. For cases when vApp template has more than one VM. string null no

Outputs

Name Description
id The ID of the VM.
ip The IP's of the VM.

Examples

module "vm" {
  source               = "git::https://github.com/noris-network/terraform-vcd-vapp-vm?ref=1.0.0"
  name                 = "web01.example.net"
  vdc_org_name         = "myORG"
  vdc_name             = "myDC01"
  cpus                 = 2
  catalog_name         = "myCatalog"
  vapp_template_name   = "debian11"
  memory               = 1024
  storage_profile_name = "myDatastorePolicy"
  network              = {
          "TEST-NET" = {
            ip_allocation_mode = "MANUAL"
            ip                 = "192.168.0.10"
            is_primary         = true
          },
        }
  guest_properties = {
    "user-data" = base64encode(templatefile("./templates/cloudinit.yaml", {
      hostname     = "web01.example.net"
      eth0_ip      = "192.168.0.10",
      eth0_netmask = "24"
      eth0_gateway = "192.168.0.1"
    }))
  }
  customization = { enabled = true }
}

Cloud Init Template

#cloud-config

hostname: ${hostname}
users:
  - name: testuser
    ssh-authorized-keys:
    - ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEc7+easbd9qfpyP1qaAvuFVMGqiKmAulEHS/VDEK3LFrRYLC [email protected]
    sudo: ['ALL=(ALL) NOPASSWD:ALL']
    groups: sudo
    shell: /bin/bash
    lock_passwd: false
network:
  version: 2
  ethernets:
    eth0:
      addresses:
        - ${eth0_ip}/${eth0_netmask}
      gateway4: ${eth0_gateway}
      nameservers:
        search: []
        addresses: [8.8.8.8]

About

Terraform module which manages standalone VM ressources on VMWare Cloud Director.

Topics

Resources

Stars

Watchers

Forks

Languages