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

fix(vm): missing disks when importing VM to a TF state #877

Merged
merged 2 commits into from
Jan 11, 2024
Merged

Conversation

bpg
Copy link
Owner

@bpg bpg commented Jan 11, 2024

Contributor's Note

  • I have added / updated documentation in /docs for any user-facing features or additions.
  • I have added / updated templates in /example for any new or updated resources / data sources.
  • I have ran make example to verify that the change works as expected.

Proof of Work

Having this VM in PVE:
Screenshot 2024-01-10 at 10 25 58 PM

Import:

❯ terraform import proxmox_virtual_environment_vm.test pve/1000
proxmox_virtual_environment_vm.test: Importing from ID "pve/1000"...
proxmox_virtual_environment_vm.test: Import prepared!
  Prepared proxmox_virtual_environment_vm for import
proxmox_virtual_environment_vm.test: Refreshing state... [id=1000]

Import successful!

The resources that were imported are shown above. These resources are now in
your Terraform state and will henceforth be managed by Terraform.

Check the state:

❯ terraform state show proxmox_virtual_environment_vm.test
# proxmox_virtual_environment_vm.test:
resource "proxmox_virtual_environment_vm" "test" {
    acpi                    = true
    bios                    = "seabios"
    id                      = "1000"
    ipv4_addresses          = [
        [
            "127.0.0.1",
        ],
        [
            "192.168.3.247",
        ],
    ]
    ipv6_addresses          = [
        [
            "::1",
        ],
        [
            "fe80::be24:11ff:fec2:8b6d",
        ],
    ]
    keyboard_layout         = "en-us"
    mac_addresses           = [
        "00:00:00:00:00:00",
        "BC:24:11:C2:8B:6D",
    ]
    name                    = "test"
    network_interface_names = [
        "lo",
        "eth0",
    ]
    node_name               = "pve"
    scsi_hardware           = "virtio-scsi-pci"
    started                 = true
    tablet_device           = true
    tags                    = []
    template                = false
    vm_id                   = 1000

    agent {
        enabled = true
        timeout = "15m"
        trim    = false
        type    = "virtio"
    }

    cpu {
        cores      = 2
        flags      = []
        hotplugged = 0
        limit      = 0
        numa       = false
        sockets    = 1
        type       = "qemu64"
        units      = 1024
    }

    disk {
        cache             = "none"
        datastore_id      = "local-lvm"
        discard           = "on"
        file_format       = "raw"
        interface         = "virtio0"
        iothread          = true
        path_in_datastore = "vm-1000-disk-0"
        size              = 20
        ssd               = false
    }

    initialization {
        datastore_id      = "local-lvm"
        interface         = "ide2"
        user_data_file_id = "local:snippets/cloud-config.yaml"

        ip_config {
            ipv4 {
                address = "dhcp"
            }
        }
    }

    memory {
        dedicated = 2048
        floating  = 0
        shared    = 0
    }

    network_device {
        bridge      = "vmbr0"
        enabled     = true
        firewall    = false
        mac_address = "BC:24:11:C2:8B:6D"
        model       = "virtio"
        mtu         = 0
        queues      = 0
        rate_limit  = 0
        vlan_id     = 0
    }

    operating_system {
        type = "l26"
    }
}

Community Note

  • Please vote on this pull request by adding a 👍 reaction to the original pull request comment to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for pull request followers and do not help prioritize the request

Closes #782

Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
Copy link

@mergify mergify bot left a comment

Choose a reason for hiding this comment

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

🤖 LGTM! beep boop

@bpg bpg merged commit a8bf497 into main Jan 11, 2024
8 checks passed
@bpg bpg deleted the fix-vm-disk-import branch January 11, 2024 03:46
@ghost ghost mentioned this pull request Jan 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Import VM to state disk missing
1 participant