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

Can't get IPV4 addresses output #398

Open
b4stien opened this issue Sep 20, 2024 · 2 comments
Open

Can't get IPV4 addresses output #398

b4stien opened this issue Sep 20, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@b4stien
Copy link

b4stien commented Sep 20, 2024

Hello and many thanks for your work on this project!

At my company we try to automate the interactions with Proxmox via Pulumi. At the moment we're unable to get the IPV4 addresses of our VMs via your provider (FTR the IPV4 is available and displayed on the Proxmox interface).

I've put a repro in this repository. The setup is minimal and described below.

The VM Template is created directly on the Proxmox host from the Debian base image :

# Download image
wget https://cloud.debian.org/images/cloud/bookworm/latest/debian-12-generic-amd64.qcow2
mv debian-12-generic-amd64.qcow2 d12-ci.qcow2

# Customize image
virt-customize -a d12-ci.qcow2 --install qemu-guest-agent
virt-customize -a d12-ci.qcow2 --truncate /etc/machine-id

# Setup image as template in Proxmox
qm create 667 --name "d12-ci-ready" --memory 2048 --cores 2 --net0 virtio,bridge=vmbr0
qm importdisk 667 d12-ci.qcow2 local-lvm
qm set 667 --scsihw virtio-scsi-pci --scsi0 local-lvm:vm-667-disk-0,ssd=1
qm set 667 --boot c --bootdisk scsi0
qm set 667 --ide2 local-lvm:cloudinit
qm set 667 --serial0 socket --vga serial0
qm set 667 --agent enabled=1
qm template 667

The VM is then launched with Pulumi via your provider :

const vm = new proxmox.vm.VirtualMachine(
  "simple-vm",
  {
    nodeName: proxmoxNodeName,
    agent: { enabled: true },
    started: true,
    clone: { full: true, vmId: 667, nodeName: proxmoxNodeName },
    initialization: {
      ipConfigs: [{ ipv4: { address: "dhcp" } }],
    },
    stopOnDestroy: true,
  },
  {
    provider: provider,
  }
);

But the output stays empty/undefined :

     Type                            Name               Status              Info
 +   pulumi:pulumi:Stack             promox-pulumi-dev  created (14s)       1 warning; 1 message
 +   ├─ pulumi:providers:proxmoxve   proxmoxve          created (0.41s)
 +   └─ proxmoxve:VM:VirtualMachine  simple-vm          created (12s)

Diagnostics:
  pulumi:pulumi:Stack (promox-pulumi-dev):
    undefined

    warning: Undefined value (ipv4Addresses) will not show as a stack output.

But in the Proxmox's interface it's available :
Screenshot 2024-09-20 at 14 17 34

@muhlba91
Copy link
Owner

hi,

i'll try to investigate within the next days; however, did you check if this behaviour is the same when using the underlying terraform provider (https://github.com/bpg/terraform-provider-proxmox)?

the pulumi provider bridges the TF provider; hence, if the TF provider is the cause, this will come through to pulumi.

@b4stien
Copy link
Author

b4stien commented Sep 21, 2024

I've updated my repro repository to include Terraform: it works.

Full output follow

proxmox_virtual_environment_vm.proxmox_vm: Refreshing state... [id=102]

Note: Objects have changed outside of OpenTofu

OpenTofu detected the following changes made outside of OpenTofu since the last "tofu apply" which may have affected this plan:

  # proxmox_virtual_environment_vm.proxmox_vm has been deleted
  - resource "proxmox_virtual_environment_vm" "proxmox_vm" {
        id                      = "102"
      - ipv4_addresses          = [] -> null
        name                    = "simple-vm-via-opentofu"
        # (25 unchanged attributes hidden)

        # (3 unchanged blocks hidden)
    }


Unless you have made equivalent changes to your configuration, or ignored the relevant attributes using ignore_changes, the following plan may include actions to undo or respond to these changes.

──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

OpenTofu used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  + create

OpenTofu will perform the following actions:

  # proxmox_virtual_environment_vm.proxmox_vm will be created
  + resource "proxmox_virtual_environment_vm" "proxmox_vm" {
      + acpi                    = true
      + bios                    = "seabios"
      + id                      = (known after apply)
      + ipv4_addresses          = (known after apply)
      + ipv6_addresses          = (known after apply)
      + keyboard_layout         = "en-us"
      + mac_addresses           = (known after apply)
      + migrate                 = false
      + name                    = "simple-vm-via-opentofu"
      + network_interface_names = (known after apply)
      + node_name               = "proxmox"
      + on_boot                 = true
      + protection              = false
      + reboot                  = false
      + scsi_hardware           = "virtio-scsi-pci"
      + started                 = true
      + stop_on_destroy         = true
      + tablet_device           = true
      + template                = false
      + timeout_clone           = 1800
      + timeout_create          = 1800
      + timeout_migrate         = 1800
      + timeout_move_disk       = 1800
      + timeout_reboot          = 1800
      + timeout_shutdown_vm     = 1800
      + timeout_start_vm        = 1800
      + timeout_stop_vm         = 300
      + vm_id                   = (known after apply)

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

      + clone {
          + full      = true
          + node_name = "proxmox"
          + retries   = 1
          + vm_id     = 667
        }

      + initialization {
          + datastore_id = "local-lvm"
          + upgrade      = (known after apply)

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

Plan: 1 to add, 0 to change, 0 to destroy.

Changes to Outputs:
  ~ instance_ips = [] -> (known after apply)

Do you want to perform these actions?
  OpenTofu will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

proxmox_virtual_environment_vm.proxmox_vm: Creating...
proxmox_virtual_environment_vm.proxmox_vm: Still creating... [10s elapsed]
proxmox_virtual_environment_vm.proxmox_vm: Still creating... [20s elapsed]
proxmox_virtual_environment_vm.proxmox_vm: Creation complete after 21s [id=101]

Apply complete! Resources: 1 added, 0 changed, 0 destroyed.

Outputs:

instance_ips = tolist([
  tolist([
    "127.0.0.1",
  ]),
  tolist([
    "10.1.15.238",
  ]),
])

@muhlba91 muhlba91 added the bug Something isn't working label Oct 17, 2024
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

No branches or pull requests

2 participants