From 397639806245b21100f8f5bdd5751131309db9ef Mon Sep 17 00:00:00 2001 From: Samy Coenen Date: Fri, 17 Jul 2020 12:15:43 +0200 Subject: [PATCH] Add cpu, mem reservations --- README.md | 3 +++ main.tf | 4 ++++ variables.tf | 11 +++++++++++ 3 files changed, 18 insertions(+) diff --git a/README.md b/README.md index 964d58d..e1a6a1c 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,7 @@ This Terraform module deploys single or multiple virtual machines of type (Linux - Ability to configure advance features for the vm. - Ability to deploy either a datastore or a datastore cluster. - Ability to enable cpu and memory hot plug features for the VM. +- Ability to enable cpu and memory reservations for the VM. - Ability to define different datastores for data disks. - Ability to define different scsi_controllers per disk, including data disks. - Ability to define network type per interface and disk label per attached disk. @@ -100,6 +101,8 @@ module "example-server-windowsvm-advanced" { instances = 2 cpu_number = 2 ram_size = 2096 + cpu_reservation = 2000 + memory_reservation = 2000 cpu_hot_add_enabled = "true" cpu_hot_remove_enabled = "true" memory_hot_add_enabled = "true" diff --git a/main.tf b/main.tf index 531b10c..3f2b9c9 100644 --- a/main.tf +++ b/main.tf @@ -82,6 +82,8 @@ resource "vsphere_virtual_machine" "Linux" { num_cores_per_socket = var.num_cores_per_socket cpu_hot_add_enabled = var.cpu_hot_add_enabled cpu_hot_remove_enabled = var.cpu_hot_remove_enabled + cpu_reservation = var.cpu_reservation + memory_reservation = var.memory_reservation memory = var.ram_size memory_hot_add_enabled = var.memory_hot_add_enabled guest_id = data.vsphere_virtual_machine.template.guest_id @@ -175,6 +177,8 @@ resource "vsphere_virtual_machine" "Windows" { num_cores_per_socket = var.num_cores_per_socket cpu_hot_add_enabled = var.cpu_hot_add_enabled cpu_hot_remove_enabled = var.cpu_hot_remove_enabled + cpu_reservation = var.cpu_reservation + memory_reservation = var.memory_reservation memory = var.ram_size memory_hot_add_enabled = var.memory_hot_add_enabled guest_id = data.vsphere_virtual_machine.template.guest_id diff --git a/variables.tf b/variables.tf index 1c70218..da17b90 100644 --- a/variables.tf +++ b/variables.tf @@ -27,6 +27,12 @@ variable "cpu_number" { default = 2 } +variable "cpu_reservation" { + description = "The amount of CPU (in MHz) that this virtual machine is guaranteed." + default = null +} + + variable "ram_size" { description = "VM RAM size in megabytes" default = 4096 @@ -150,6 +156,11 @@ variable "memory_hot_add_enabled" { default = null } +variable "memory_reservation" { + description = "The amount of memory (in MB) that this virtual machine is guaranteed." + default = null +} + variable "disk_label" { description = "Storage data disk labels" type = list