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

Cloning template with cloud-init drive set fails when using initialization block #174

Closed
michalg91 opened this issue Dec 6, 2022 · 0 comments · Fixed by #175
Closed
Labels
🐛 bug Something isn't working

Comments

@michalg91
Copy link
Contributor

michalg91 commented Dec 6, 2022

Describe the bug
When i tried to provision with vm template containing cloud init drive, provisioner is going to create the drive and Proxmox api is responding with 500 error, because file was created with clone task.
│ Error: received an HTTP 500 response - Reason: rbd create 'vm-100-cloudinit' error: rbd: create error: (17) File exists

To Reproduce
Steps to reproduce the behavior:

  1. create vm template in proxmox with cloud-init drive (ide2) attached and generate config
  2. provision vm with clone method and use initialization block
  3. See error

Expected behavior
VM clone should finish and then cloudinit drive should be recreated/skipped if it exists in template.

Sample vm

resource "proxmox_virtual_environment_vm" "k8s_master" {
    provider = proxmox.pve
    count = var.vm_count.k8s_masters
    node_name = random_shuffle.k8s_masters.result[count.index]
    description = "created by terraform - username ${var.vm_user.username}"


    name = "${var.hostname}-master${count.index+1}"
    clone {
        datastore_id = "vms"
        vm_id = 9202
        node_name = data.proxmox_virtual_environment_nodes.pve.names[0]
    }
    agent {
        enabled = true
        trim = true
    }
    cpu {
        type = "host"
        cores = 4
        sockets = 2
    }

    memory {
        dedicated = 1024*8
    }

    disk {
        datastore_id = "vms"
        interface = "scsi0"
        size = "100"
        discard = "on"
    }

    network_device {
      bridge = "vmbr0"
      model = "virtio"
      vlan_id = 3031
    }

    on_boot = true
    operating_system {
      type = "l26"
    }

    vga {
        type = "qxl"
    }

    serial_device {
      device = "socket"
    }

    initialization {
        vendor_data_file_id = "shared:snippets/one.yaml"
        user_account {
            keys = [trimspace(var.vm_user.ssh_pub_key)]
            password = var.vm_user_password
            username = var.vm_user.username
        }
        datastore_id = "vms"
        ip_config {
            ipv4 {
                address = "172.26.7.${131+count.index}/25"
                gateway = "172.26.7.129"
            }
        }
    }
    lifecycle {
        ignore_changes = [
            node_name,
            network_interface_names,
            initialization[0].user_account,
            initialization[0].user_data_file_id,
            clone
        ]
    }
}
@michalg91 michalg91 added the 🐛 bug Something isn't working label Dec 6, 2022
michalg91 added a commit to michalg91/terraform-provider-proxmox that referenced this issue Dec 7, 2022
michalg91 added a commit to michalg91/terraform-provider-proxmox that referenced this issue Dec 7, 2022
@bpg bpg closed this as completed in #175 Dec 10, 2022
bpg added a commit that referenced this issue Dec 10, 2022
* fix: Remove cloned ide2 before creating new one (#174)

* add test case to `/examples`

Co-authored-by: Michał Gawryś <mgawrys@netbyte.pl>
Co-authored-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
@ghost ghost mentioned this issue Dec 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant