[GH-ISSUE #214] Improve Cloud-Init ipconfig[n] #44

Closed
opened 2026-02-28 00:40:19 +03:00 by kerem · 3 comments
Owner

Originally created by @sebastian-de on GitHub (Nov 3, 2022).
Original GitHub issue: https://github.com/Telmate/proxmox-api-go/issues/214

While working with packer-plugin-proxmox, which also uses this project, I had a look at how ipconfig-entries for Cloud-Init are handled.
The way it works right now makes it quite clumsy to add the relevant support to Packer.

Right now a config block looks like this:

{
  "network": {
    "0": {
      "model": "virtio",
      "bridge": "vmbr0",
    }
  }
  "ipconfig0": "gw=10.0.2.2,ip=10.0.2.17/24"
}

I would like to define the ipconfig inside every network card block like this:

{
  "network": {
    "0": {
      "model": "virtio",
      "bridge": "vmbr0",
      "ipconfig": "gw=10.0.2.2,ip=10.0.2.17/24"
    }
  }
}

I know that this is a breaking change, but I think this makes the configuration (and code) a lot cleaner.
I'm making a PR ready, please let me know what you think!

Originally created by @sebastian-de on GitHub (Nov 3, 2022). Original GitHub issue: https://github.com/Telmate/proxmox-api-go/issues/214 While working with [packer-plugin-proxmox](https://github.com/hashicorp/packer-plugin-proxmox/), which also uses this project, I had a look at how ipconfig-entries for Cloud-Init are handled. The way it works right now makes it quite clumsy to add the relevant support to Packer. Right now a config block looks like this: ```json { "network": { "0": { "model": "virtio", "bridge": "vmbr0", } } "ipconfig0": "gw=10.0.2.2,ip=10.0.2.17/24" } ``` I would like to define the `ipconfig` inside every network card block like this: ```json { "network": { "0": { "model": "virtio", "bridge": "vmbr0", "ipconfig": "gw=10.0.2.2,ip=10.0.2.17/24" } } } ``` I know that this is a breaking change, but I think this makes the configuration (and code) a lot cleaner. I'm making a PR ready, please let me know what you think!
kerem closed this issue 2026-02-28 00:40:19 +03:00
Author
Owner

@mleone87 commented on GitHub (Nov 4, 2022):

Hello @sebastian-de and thanks for your work!
To be honest, I would love to stick to the API structure made by proxmox, this is only a wrapper for the api and the net[n] api object has no ipiconfig[n] in it. In fact, one can create a network without cloud init support(I know, we can always omit it the json)

In this api there is a notable -broken- exception for the disk where the sata/virtio/scsi[n] and that should be fixed too

I see no problem in making ipiconfig0-15 objects a more concise structure

{
  "ipconfig": {
    "0": {
      "ip": "192.168.1.1"
    }
  }
}
<!-- gh-comment-id:1303787937 --> @mleone87 commented on GitHub (Nov 4, 2022): Hello @sebastian-de and thanks for your work! To be honest, I would love to stick to the API structure made by proxmox, this is only a wrapper for the api and the net[n] api object has no ipiconfig[n] in it. In fact, one can create a network without cloud init support(I know, we can always omit it the json) In this api there is a notable -broken- exception for the disk where the sata/virtio/scsi[n] and that should be fixed too I see no problem in making ipiconfig0-15 objects a more concise structure ```json { "ipconfig": { "0": { "ip": "192.168.1.1" } } } ```
Author
Owner

@sebastian-de commented on GitHub (Nov 4, 2022):

Hey @mleone87 , thank you for your feedback!

Hello @sebastian-de and thanks for your work! To be honest, I would love to stick to the API structure made by proxmox, this is only a wrapper for the api and the net[n] api object has no ipiconfig[n] in it.

I guess you're right in sticking to to Proxmox API as close as possible. Since ipconfig[n] and net[n] are mapped on the Proxmox side, I thought it made sense to declare them together. But thinking about it again, it makes more sense to separate Qemu and Cloud-Init options.

Since I don't think that it's worth the hassle to split the ipconfig-strings themselves, what do you think about just doing this:

{
  "ipconfig": {
    "0": "gw=10.0.2.2,ip=10.0.2.17/24",
    "1": "gw=10.0.3.1,ip=10.0.3.20/24"
  }
}

This could be implemented without breaking the API (I think), but we would still get rid of the sixteen hardcoded ipconfig entries.
If desired, the ipconfig strings could be split in a second step.

<!-- gh-comment-id:1303885361 --> @sebastian-de commented on GitHub (Nov 4, 2022): Hey @mleone87 , thank you for your feedback! > Hello @sebastian-de and thanks for your work! To be honest, I would love to stick to the API structure made by proxmox, this is only a wrapper for the api and the net[n] api object has no ipiconfig[n] in it. I guess you're right in sticking to to Proxmox API as close as possible. Since ipconfig[n] and net[n] are mapped on the Proxmox side, I thought it made sense to declare them together. But thinking about it again, it makes more sense to separate Qemu and Cloud-Init options. Since I don't think that it's worth the hassle to split the ipconfig-strings themselves, what do you think about just doing this: ```json { "ipconfig": { "0": "gw=10.0.2.2,ip=10.0.2.17/24", "1": "gw=10.0.3.1,ip=10.0.3.20/24" } } ``` ~~This could be implemented without breaking the API (I think),~~ but we would still get rid of the sixteen hardcoded ipconfig entries. If desired, the ipconfig strings could be split in a second step.
Author
Owner

@mleone87 commented on GitHub (Dec 1, 2022):

We can close I guess, merged!

<!-- gh-comment-id:1333479577 --> @mleone87 commented on GitHub (Dec 1, 2022): We can close I guess, merged!
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/proxmox-api-go#44
No description provided.