Skip to content

[3.0.2-rc05] Get LXC container IP when interface set to dhcp #1453

@ncapeyron

Description

@ncapeyron

Hi,

plugin version : 3.0.2-rc05
terraform version : 1.13.5

After creating a simple LXC container like this (with ip = dhcp) :

resource "proxmox_lxc" "debian_container" {
  target_node  = "proxmox2"
  hostname     = "test-lxc-4"
  ostemplate   = "local:vztmpl/debian-12-standard_12.7-1_amd64.tar.zst"
  password     = "xxxxxxxxxxxxxx"
  unprivileged = true

  rootfs {
    storage = "local-lvm"
    size    = "8G"
  }
  
  tags           = "test"

  network {
    name   = "eth0"
    bridge = "vmbr0"
    ip     = "dhcp"
  }
  start = true
}

I cannot retrieve the IP address assigned by DHCP to the container.

$ terraform show

# proxmox_lxc.debian_container:
resource "proxmox_lxc" "debian_container" {
    arch                 = "amd64"
    bwlimit              = 0
    cmode                = "tty"
    console              = true
    cores                = 0
    cpulimit             = 0
    cpuunits             = 1024
    current_node         = "proxmox2"
    description          = null
    force                = false
    hagroup              = null
    hastate              = null
    hookscript           = null
    hostname             = "test-lxc-4"
    id                   = "proxmox2/lxc/20214"
    ignore_unpack_errors = false
    lock                 = null
    memory               = 512
    nameserver           = null
    onboot               = false
    ostemplate           = "local:vztmpl/debian-12-standard_12.7-1_amd64.tar.zst"
    ostype               = "debian"
    password             = (sensitive value)
    protection           = false
    restore              = false
    searchdomain         = null
    start                = true
    startup              = null
    swap                 = 0
    tags                 = "test"
    target_node          = "proxmox2"
    template             = false
    tty                  = 2
    unique               = false
    unprivileged         = true
    unused               = []
    vmid                 = 20214

    network {
        bridge   = "vmbr0"
        firewall = false
        gw       = null
        gw6      = null
        hwaddr   = "BC:24:11:20:AA:06"
        id       = 0
        ip       = "dhcp"
        ip6      = null
        mtu      = 0
        name     = "eth0"
        rate     = 0
        tag      = 0
        trunks   = null
        type     = "veth"
    }

    rootfs {
        acl       = false
        quota     = false
        replicate = false
        ro        = false
        shared    = false
        size      = "8G"
        storage   = "local-lvm"
        volume    = "local-lvm:vm-20214-disk-0"
    }
}

The IP is correctly returned by the API :

 # root@proxmox2:~# pvesh get /nodes/proxmox2/lxc/20214/interfaces
┌───────────────────┬───────────────────┬───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┬──────┬─────────────────┬──────────────────────────────┐
│ hardware-address  │ hwaddr            │ ip-addresses                                                                                                                                              │ name │ inet            │ inet6                        │
╞═══════════════════╪═══════════════════╪═══════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════╪══════╪═════════════════╪══════════════════════════════╡
│ 00:00:00:00:00:00 │ 00:00:00:00:00:00 │ [{"ip-address":"127.0.0.1","ip-address-type":"inet","prefix":"8"},{"ip-address":"::1","ip-address-type":"inet6","prefix":"128"}]                          │ lo   │ 127.0.0.1/8     │ ::1/128                      │
├───────────────────┼───────────────────┼───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┼──────┼─────────────────┼──────────────────────────────┤
│ bc:24:11:20:aa:06 │ bc:24:11:20:aa:06 │ [{"ip-address":"192.168.0.98","ip-address-type":"inet","prefix":"24"},{"ip-address":"fe80::be24:11ff:fe20:aa06","ip-address-type":"inet6","prefix":"64"}] │ eth0 │ 192.168.0.98/24 │ fe80::be24:11ff:fe20:aa06/64 │
└───────────────────┴───────────────────┴───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┴──────┴─────────────────┴──────────────────────────────┘
root@proxmox2:~# 

Any suggestion ?

Thx for your work !

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions