orange-cloudavenue/terraform-provider-cloudavenue

[Bug]: Provider produced inconsistent result after apply

Closed this issue · 2 comments

Terraform Core Version

v1.7.2

Cloud Avenue Provider Version

0.18.4

Affected Resource(s)

cloudavenue_vm

Expected Behavior

I am using clouavenue_vm resource and while adding the below attributes for customization, i found that the provider is showing unexpected behavior of changing the auto_generate_password to false insteed of true as defined in the desired state.

#########################################
customization = {
      enable = "true"
      auto_generate_password = "true"
     # allow_local_admin_password = true
    }

##########################################

Below is the output in the terminal

Error: Provider produced inconsistent result after apply
│
│ When applying changes to cloudavenue_vm.ranchernode01, provider "provider[\"registry.terraform.io/orange-cloudavenue/cloudavenue\"]" produced an unexpected new value: .settings.customization.auto_generate_password: was cty.True, but   
│ now cty.False.
│
│ This is a bug in the provider, which should be reported in the provider's own issue tracker.

Actual Behavior

The actual behavior is to enable auto_generate_password to true

Relevant Error/Panic Output Snippet

Error: Provider produced inconsistent result after apply
│
│ When applying changes to cloudavenue_vm.ranchernode01, provider "provider[\"registry.terraform.io/orange-cloudavenue/cloudavenue\"]" produced an unexpected new value: .settings.customization.auto_generate_password: was cty.True, but   
│ now cty.False.
│
│ This is a bug in the provider, which should be reported in the provider's own issue tracker.

Terraform Configuration Files

data "cloudavenue_edgegateway" "edgegw" {
  name = "*******************"
}

data "cloudavenue_network_routed" "myrouted" {
  name            = "************"
  edge_gateway_id =  data.cloudavenue_edgegateway.edgegw.id
}

data "cloudavenue_catalog_vapp_template" "ranchertemplate" {
  catalog_name  = "********************"
  template_name = "****************"
}

output "template_id" {
    value = data.cloudavenue_catalog_vapp_template.ranchertemplate
}

resource "cloudavenue_vapp" "ranchervapp" {
  name        = "Rancher"
  description = "This vApp is created using terraform. Please Please_refrain_to_do_direct_changes_to_it"
  vdc = "*********"

  lease = {
    runtime_lease_in_sec = 3600
    storage_lease_in_sec = 3600
  }

  guest_properties = {
    "node" = "rancher"
  }
}

resource "cloudavenue_vapp_org_network" "myvappnetwork" {
  vapp_name    = cloudavenue_vapp.ranchervapp.name
  vdc         = "*********"
  network_name = data.cloudavenue_network_routed.myrouted.name
}

resource "cloudavenue_vm_affinity_rule" "myantiaffinityrule" {
  name     = "rancher-antiaffinity-rule"
  polarity = "Anti-Affinity"

  vm_ids = [
    cloudavenue_vm.ranchernode01.id,
    cloudavenue_vm.ranchernode02.id,
    cloudavenue_vm.ranchernode03.id,
  ]
}

resource "cloudavenue_vm" "ranchernode01" {
    name        = "ranchernode01"
    description = "This VM is created using rancher. Please_refrain_to_do_direct_changes_to_it"
    vapp_name = cloudavenue_vapp.ranchervapp.name
    vdc = "*********"
    deploy_os = {
    vapp_template_id = data.cloudavenue_catalog_vapp_template.ranchertemplate.id
    accept_all_eulas = true
  } 
    settings = {
    guest_properties = {
      "guestinfo.hostname" = "************"
    }
    **customization = {
      enable = "true"
      auto_generate_password = "true"
     # allow_local_admin_password = true
    }**
    
  }
  resource = {
    cpus   = 4
    memory = 4096
    networks = [
      {
        type               = "org"
        name               = cloudavenue_vapp_org_network.myvappnetwork.network_name
        ip                 = "*********"
        ip_allocation_mode = "MANUAL"
        is_primary         = true
      }
    ]
  }
   state = {
    power_on = true
  }
}

resource "cloudavenue_vm" "ranchernode02" {
    name        = "ranchernode02"
    description = "This VM is created using rancher. Please_refrain_to_do_direct_changes_to_it"
    vapp_name = cloudavenue_vapp.ranchervapp.name
    vdc = "*********"
    deploy_os = {
      vapp_template_id = data.cloudavenue_catalog_vapp_template.ranchertemplate.id
    }
        settings = {
    guest_properties = {
      "guestinfo.hostname" = "ranchernode02"
    }
    **customization = {
      enable = "true"
      auto_generate_password = "true"
     # allow_local_admin_password = true
    }**
  }
  resource = {
    cpus   = 4
    memory = 4096
    networks = [
      {
        type               = "org"
        name               = cloudavenue_vapp_org_network.myvappnetwork.network_name
        ip                 = "*********"
        ip_allocation_mode = "MANUAL"
        is_primary         = true
      }
    ]
  }
  state = {
    power_on = true
  }
}

resource "cloudavenue_vm" "ranchernode03" {
    name        = "ranchernode03"
    description = "This VM is created using rancher. Please_refrain_to_do_direct_changes_to_it"
    vapp_name = cloudavenue_vapp.ranchervapp.name
    vdc = "**********"
    deploy_os = {
      vapp_template_id = data.cloudavenue_catalog_vapp_template.ranchertemplate.id
    }
        settings = {
    guest_properties = {
      "guestinfo.hostname" = "ranchernode03"
    }
    **customization = {
      enable = "true"
      auto_generate_password = "true"
     # allow_local_admin_password = true

    }**
  }
  resource = {
    cpus   = 4
    memory = 4096
    networks = [
      {
        type               = "org"
        name               = cloudavenue_vapp_org_network.myvappnetwork.network_name
        ip                 = "**************"
        ip_allocation_mode = "MANUAL"
        is_primary         = true
      }
    ]
  }
  state = {
    power_on = true
  }
}

Steps to Reproduce

Just run the above code by adding required cloudavenue org related objects

Debug Output

No response

Panic Output

No response

Important Factoids

No response

References

No response

Would you like to implement a fix?

None

Hi @htshshrm2,

Your terraform configuration is invalid.

resource "cloudavenue_vm" "ranchernode02" {
    name        = "ranchernode02"
[...]
    customization = {
      enabled = true
      auto_generate_password = true
     # allow_local_admin_password = true
    }
  }
[...]

The field enable doesn't exist doc. Use enabled instead enable and set true in boolean format.

If the VM already exist use force attribute.

Regards

Hi,

If you do not receive a response, I will close this issue. If the problem persists, please reopen a new issue.