Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add disabled to vsphere_ha_vm_override #1505

Merged
merged 1 commit into from
Jan 28, 2022
Merged

Add disabled to vsphere_ha_vm_override #1505

merged 1 commit into from
Jan 28, 2022

Conversation

tenthirtyam
Copy link
Collaborator

Description

  • Adds disabledoption to vsphere_ha_vm_overide resource.
  • Updates vsphere_ha_vm_overideresource docs to include disabled.
  • Updates vsphere_ha_vm_overideresource docs to vSphere 7.0 reference.

Acceptance tests

  • Have you added an acceptance test for the functionality being added?
  • Have you run the acceptance tests on this branch?

Contributor Note: Performed unit tests which included both positive and negative tests. All passed successfully.

Example:

variables.tf

##################################################################################
# VARIABLES
##################################################################################

# Credentials

variable "vsphere_server" {
  type        = string
  description = "The fully qualified domain name or IP address of the vCenter Server instance."
}

variable "vsphere_username" {
  type        = string
  description = "The username to login to the vCenter Server instance."
}

variable "vsphere_password" {
  type        = string
  description = "The password for the login to the vCenter Server instance."
}

variable "vsphere_insecure" {
  type        = bool
  description = "Set to true for self-signed certificates."
  default     = false
}

# vSphere Objects

variable "vsphere_datacenter" {
  type        = string
  description = "The target vSphere datacenter object name (e.g. sfo-m01-dc01)"
}

variable "vsphere_cluster" {
  type        = string
  description = "The target vSphere cluster object name (e.g. sfo-m01-cl01)"
}

# vSphere HA - Virtual Machinee Startup Priority Overrides

variable "overrides" {
  type = map(object({
    vm    = string
    level = string
  }))
  description = "A mapping of objects and their priority level."
}

terraform.tfvars

##################################################################################
# VARIABLES
##################################################################################

# Credentials

vsphere_server   = "sfo-m01-vc01.rainpole.io"
vsphere_username = "svc-terraform-vsphere@rainpole.io"
vsphere_password = "************"
vsphere_insecure = false

# vSphere Objects

vsphere_datacenter = "sfo-m01-dc01"
vsphere_cluster    = "sfo-m01-cl01"

# vSphere HA - Virtual Machine Startup Priority Overrides

overrides = {
  override0 = {
    vm = "ubuntu-0"
    level = "disabled"
  }
  override1 = {
    vm = "ubuntu-1"
    level = "disabled"
  }
}

main.tf

terraform {
  required_providers {
    vsphere = {
      source  = "local/vmware/vsphere"
      version = "x.y.z"
    }
  }
  required_version = ">= 1.0.9"
}

##################################################################################
# PROVIDERS
##################################################################################

provider "vsphere" {
  vsphere_server       = var.vsphere_server
  user                 = var.vsphere_username
  password             = var.vsphere_password
  allow_unverified_ssl = var.vsphere_insecure
}

##################################################################################
# DATA
##################################################################################

data "vsphere_datacenter" "dc" {
  name = var.vsphere_datacenter
}

data "vsphere_compute_cluster" "cluster" {
  name          = var.vsphere_cluster
  datacenter_id = data.vsphere_datacenter.dc.id
}

data "vsphere_virtual_machine" "vm" {
  for_each      = var.overrides
  name          = each.value["vm"]
  datacenter_id = data.vsphere_datacenter.dc.id
}

##################################################################################
# RESOURCES
##################################################################################

resource "vsphere_ha_vm_override" "ha_vm_override" {
  for_each           = var.overrides
  compute_cluster_id = data.vsphere_compute_cluster.cluster.id
  virtual_machine_id = data.vsphere_virtual_machine.vm[each.key].id
  ha_vm_restart_priority = each.value["level"]
}

Release Note

Release note for CHANGELOG:

Adds `disabled` option to `vsphere_ha_vm_override` resource.

References

Resolves #1493

Addresses #1493
- Adds `disabled` to `vsphere_ha_vm_overide`.
- Updates `vsphere_ha_vm_overide`resource docs to include `disabled`.
- Updates `vsphere_ha_vm_overide`resource docs to vSphere 7.0 reference.

Signed-off-by: Ryan Johnson <johnsonryan@vmware.com>
@github-actions github-actions bot added documentation Type: Documentation size/xs Relative Sizing: Extra-Small labels Oct 30, 2021
@appilon
Copy link
Contributor

appilon commented Jan 28, 2022

I was teetering on asking for a test for this, however our existing acceptance tests only have an example for "highest" and don't validate the other settings.

@appilon appilon merged commit 3c0171d into hashicorp:master Jan 28, 2022
@tenthirtyam
Copy link
Collaborator Author

Thanks for reviewing and merging, @appilon!

@tenthirtyam tenthirtyam deleted the gh-1493 branch January 28, 2022 21:32
@tenthirtyam tenthirtyam added this to the v2.1.0 milestone Feb 14, 2022
@github-actions
Copy link

github-actions bot commented Mar 2, 2022

This functionality has been released in v2.1.0 of the Terraform Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

@github-actions
Copy link

github-actions bot commented Apr 2, 2022

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 2, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation Type: Documentation size/xs Relative Sizing: Extra-Small
Projects
None yet
Development

Successfully merging this pull request may close these issues.

vsphere_ha_vm_override : missing disable state for ha_vm_restart_priority
2 participants