danitso / terraform-provider-proxmox

Terraform Provider for Proxmox
Mozilla Public License 2.0
142 stars 32 forks source link

[BUG] VM creation takes too long #27

Closed maurete closed 4 years ago

maurete commented 4 years ago

Describe the bug

When creating a new VM, the command terraform apply takes about 15 minutes and 30 seconds to complete. On the Proxmox web console, however, I can see that the machine was actually up and running after about one minute.

Am I missing something?

The Proxmox cluster is reachable via a local network connection, so it doesn't seem to be a network issue. Otherwise the plugin works wonderfully.

To Reproduce

Steps to reproduce the behavior:

  1. Use the following main.tf file:

    provider "proxmox" {
    virtual_environment {}
    }
    resource "proxmox_virtual_environment_vm" "my_test_vm" {
    name        = "my-test"
    description = "Managed by Terraform"
    node_name = "node1"
    agent {
    enabled = true
    }
    clone {
    datastore_id = "Volume-Test"
    vm_id = "10002"
    node_name = "node0"
    }
    initialization {
    ip_config {
      ipv4 {
        address = "dhcp"
      }
    }
    }
    network_device {
    vlan_id = "501"
    }
    }
  2. Run terraform plan -out plan.tfplan

  3. Run terraform apply -input=false plan.tfplan

Expected behavior

terraform apply command completing in reasonable time, similar to what can be seen in the Proxmox console.

Screenshots

terraform apply -input=false plan.tfplan
proxmox_virtual_environment_vm.my_test_vm: Creating...
proxmox_virtual_environment_vm.my_test_vm: Still creating... [10s elapsed]
# ... etc ...
proxmox_virtual_environment_vm.my_test_vm: Still creating... [15m30s elapsed]
proxmox_virtual_environment_vm.my_test_vm: Creation complete after 15m33s [id=134]
Apply complete! Resources: 1 added, 0 changed, 0 destroyed.
The state of your infrastructure has been saved to the path
below. This state is required to modify and destroy your
infrastructure, so keep it safe. To inspect the complete state
use the `terraform show` command.
State path: terraform.tfstate

Additional context

Output of terraform show after terraform apply:

# proxmox_virtual_environment_vm.my_test_vm:
resource "proxmox_virtual_environment_vm" "my_test_vm" {
    acpi                    = true
    bios                    = "seabios"
    description             = "Managed by Terraform"
    id                      = "134"
    ipv4_addresses          = []
    ipv6_addresses          = []
    keyboard_layout         = "en-us"
    mac_addresses           = []
    name                    = "my-test"
    network_interface_names = []
    node_name               = "node1"
    started                 = true
    tablet_device           = true
    template                = false
    vm_id                   = -1
    agent {
        enabled = true
        timeout = "15m"
        trim    = false
        type    = "virtio"
    }
    clone {
        datastore_id = "Volume-Test"
        node_name    = "node0"
        vm_id        = 10002
    }
    initialization {
        datastore_id = "local-lvm"
        ip_config {
            ipv4 {
                address = "dhcp"
            }
        }
        user_account {
# redacted
        }
    }
    network_device {
        bridge      = "vmbr0"
        enabled     = true
        mac_address = "7A:09:51:38:8F:D4"
        model       = "virtio"
        rate_limit  = 0
        vlan_id     = 501
    }
}
maurete commented 4 years ago

Dismiss this issue, disabled the agent and everything worked perfectly.

trey-ivy commented 3 years ago

@maurete i'm having the same issue but I don't know what you mean by 'disabled the agent' and was hoping you could provide a little bit more detail

bertogravscale commented 6 months ago

he means disable qemu guest agent in proxmox vm options here when disable it work too

if qemu guest agent is on it should be installed and running inside vm (apt install qemu-guest-agent)