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 RequiredWith to options require to join a domain #1562

Merged
merged 1 commit into from
Jan 28, 2022
Merged

Add RequiredWith to options require to join a domain #1562

merged 1 commit into from
Jan 28, 2022

Conversation

tenthirtyam
Copy link
Collaborator

Description

Adds RequiredWith to options related to joining a domain in windows_option. This will ensure all required options / arguments for joining a domain are provided.

Note: The vsphere_virtual_machine resource documentation already states as "optional", but "required if setting join_domain" Thus, no changes are required to the docs.

Building the provider with the following changes:

 "join_domain": { 
 	Type:          schema.TypeString, 
 	Optional:      true, 
 	ConflictsWith: []string{cWindowsKeyPrefix + "." + "workgroup"}, 
 	Description:   "The domain that the virtual machine should join.", 
        RequiredWith:  []string{cWindowsKeyPrefix + "." + "domain_admin_user", cWindowsKeyPrefix + "." + "domain_admin_password"},
 }, 

The results of the change are, in a plan with the following:

resource "vsphere_virtual_machine" "vm" {
  name                    = var.vm_name
  folder                  = var.vsphere_folder
  num_cpus                = var.vm_cpus
  memory                  = var.vm_memory
  firmware                = var.vm_firmware
  efi_secure_boot_enabled = var.vm_efi_secure_boot_enabled
  guest_id                = data.vsphere_virtual_machine.template.guest_id
  datastore_id            = data.vsphere_datastore.datastore.id
  resource_pool_id        = data.vsphere_resource_pool.pool.id
  network_interface {
    network_id = data.vsphere_network.network.id
  }
  disk {
    label            = "disk0"
    size             = data.vsphere_virtual_machine.template.disks.0.size
    eagerly_scrub    = data.vsphere_virtual_machine.template.disks.0.eagerly_scrub
    thin_provisioned = data.vsphere_virtual_machine.template.disks.0.thin_provisioned
  }
  clone {
    template_uuid = data.vsphere_virtual_machine.template.id
    customize {
      windows_options {
        computer_name         = var.vm_name
        join_domain           = var.domain
        domain_admin_user     = var.domain_admin_username
        domain_admin_password = var.domain_admin_password
        admin_password        = var.vm_admin_password
      }
      network_interface {
        ipv4_address = var.vm_ipv4_address
        ipv4_netmask = var.vm_ipv4_netmask
      }

      ipv4_gateway    = var.vm_ipv4_gateway
      dns_suffix_list = var.vm_dns_suffix_list
      dns_server_list = var.vm_dns_server_list
    }
  }

With domain_admin_user and domain_admin_password commented out / omitted, the following will be displayed denoting that join_domain is required arguments

terraform plan

│ Error: Missing required argument

│   with vsphere_virtual_machine.vm,
│   on main.tf line 59, in resource "vsphere_virtual_machine" "vm":
│   59:       windows_options {

│ "clone.0.customize.0.windows_options.0.domain_admin_user": all of
│ `clone.0.customize.0.windows_options.0.domain_admin_user,clone.0.customize.0.windows_options.0.join_domain` must be specified


│ Error: Missing required argument

│   with vsphere_virtual_machine.vm,
│   on main.tf line 59, in resource "vsphere_virtual_machine" "vm":
│   59:       windows_options {

│ "clone.0.customize.0.windows_options.0.domain_admin_password": all of
│ `clone.0.customize.0.windows_options.0.domain_admin_password,clone.0.customize.0.windows_options.0.join_domain` must be specified

If I comment out / omit only join_domain the following will result denoting that domain_admin_user and domain_admin_password are required arguments.

terraform plan

│ Error: Missing required argument

│   with vsphere_virtual_machine.vm,
│   on main.tf line 59, in resource "vsphere_virtual_machine" "vm":
│   59:       windows_options {

│ "clone.0.customize.0.windows_options.0.domain_admin_user": all of
│ `clone.0.customize.0.windows_options.0.domain_admin_user,clone.0.customize.0.windows_options.0.join_domain` must be specified


│ Error: Missing required argument

│   with vsphere_virtual_machine.vm,
│   on main.tf line 59, in resource "vsphere_virtual_machine" "vm":
│   59:       windows_options {

│ "clone.0.customize.0.windows_options.0.domain_admin_password": all of
│ `clone.0.customize.0.windows_options.0.domain_admin_password,clone.0.customize.0.windows_options.0.join_domain` must be specified

Release Note

`resource/virtual_machine > virtual_machine_customize_subresource` : Updates `windows_options` to ensure all required options for domain join are provided

References

Closes #1350

Adds `RequiredWith` to options related to joining a domain in `windows_option`. This will ensure all required options for joining a domain are provided.

Signed-off-by: Ryan Johnson <johnsonryan@vmware.com>
@github-actions github-actions bot added provider Type: Provider size/xs Relative Sizing: Extra-Small labels Jan 26, 2022
@appilon appilon merged commit de2cfd4 into hashicorp:master Jan 28, 2022
@tenthirtyam
Copy link
Collaborator Author

Thank you, @appilon!

@tenthirtyam tenthirtyam deleted the gh-1350 branch January 28, 2022 21:27
Copy link
Contributor

@appilon appilon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

approved

@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
provider Type: Provider size/xs Relative Sizing: Extra-Small
Projects
None yet
Development

Successfully merging this pull request may close these issues.

join_domain on Windows server not reporting a failure when failing to join the domain
2 participants