meffie / molecule-proxmox

Molecule driver for Proxmox VE
MIT License
36 stars 8 forks source link

[Feature Request] LXC support #21

Open Lithimlin opened 2 months ago

Lithimlin commented 2 months ago

Hi,

would it be possible to add support for LXCs to this driver? It can happen fairly often that a role that works on a KVM doesn't work on an LXC, especially when it concerns hardware devices.

meffie commented 2 months ago

Hello,

It would be very nice to have. I'm not currently using LXC containers very much, but it does make sense to support.

Would you need to have a mix of VMs and Containers in a single molecule scenario? Having only one or the other could simplify the implementation.

Mike --


From: JL Euler @.***> Sent: Thursday, September 19, 2024 11:16 AM To: meffie/molecule-proxmox Cc: Subscribed Subject: [meffie/molecule-proxmox] [Feature Request] LXC support (Issue #21)

Hi,

would it be possible to add support for LXCs to this driver? It can happen fairly often that a role that works on a KVM doesn't work on an LXC, especially when it concerns hardware devices.

— Reply to this email directly, view it on GitHubhttps://github.com/meffie/molecule-proxmox/issues/21, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AAIPBUQA6GJZ2OKR2I7XA23ZXLTFBAVCNFSM6AAAAABOQFEVEOVHI2DSMVQWIX3LMV43ASLTON2WKOZSGUZTMNRWHA4DIMY. You are receiving this because you are subscribed to this thread.Message ID: @.***>

IamLunchbox commented 2 months ago

Wouldnt this be very different to the current access method of molecule-proxmox? We now use primarily ansibles ssh to access the vm.

Molecule docker/podman probably uses the socket the spawn container processes so their access model is very different. @Lithimlin how would you want to access the container?

And we rely on community.general.proxmox_kvm to create/change/destroy vms. Sadly, here is no plugin for lxc manipulation in community.general right now so thered need to be a custom playbook or library to provide this feature.

Lithimlin commented 2 months ago

Would you need to have a mix of VMs and Containers in a single molecule scenario?

No, I'd imagine they'd be different scenarios.

Sadly, here is no plugin for lxc manipulation in community.general right now

There is. Its community.general.proxmox.

Wouldnt this be very different to the current access method of molecule-proxmox?

You'd access the LXC via SSH, just like the KVM.

IamLunchbox commented 2 months ago

Ah, i was mislead by the modules title. For reference: Here

meffie commented 2 months ago

It was several years ago when I last tried this. I seem to now recall the issue was some things could not be done with the API and had to be done by running pvesh on the proxmox host. That may have changed (or I could be wrong). I'll have to try again on a current version of proxmox.

Lithimlin commented 2 months ago

I've recently read into the API a bit and worked on the proxmox ansible module, so if there's anything you need help with let me know.

IamLunchbox commented 1 month ago

Sure, all contributions are welcome! I think if you would point out differences to the kvm creation that would be helpful.

And maybe you can take the create.yml playbook from this repo as a template and change it to create a lxc container - thatd be great! Just leave out the templating for the start, a smal POC probably helps most to decide if it is feasible.

The biggest problem right now is to determine the ip address of the container. We use the guest agent and a custom module for that, what can we use to reliably find the containers ip through API calls?

Sep 24, 2024 10:48:28 JL Euler @.***>:

I've recently read into the API a bit and worked on the proxmox ansible module, so if there's anything you need help with let me know.

— Reply to this email directly, view it on GitHub[https://github.com/meffie/molecule-proxmox/issues/21#issuecomment-2370656747], or unsubscribe[https://github.com/notifications/unsubscribe-auth/ANRA34KFODDU3QAIRNGE3ZLZYERNVAVCNFSM6AAAAABOQFEVEOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGNZQGY2TMNZUG4]. You are receiving this because you commented. [Tracking image][https://github.com/notifications/beacon/ANRA34ILG45EVQZLSAWPOZ3ZYERNVA5CNFSM6AAAAABOQFEVEOWGG33NNVSW45C7OR4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3TUL5UWJTUNJVM6W.gif]

meffie commented 1 month ago

Ah, yes getting the container IP address is the sticking point. The only method I was able to find required running the pvesh command on the proxmox host. If there is no API for such, we are kind of stuck.

IamLunchbox commented 1 month ago

I thought up three other mechanisms we could use:

  1. DNS, if e.g. dhcp hostname registration is configured in that network.
  2. Parsing the cloud init input for ips  (not lxc)
  3. Hardcoded ips, if the new ip is otherwise predictable.

I thought about that in the past due to networks, where several interfaces are attached. In that case the qemu agent could be unreliable?

Sep 25, 2024 15:34:53 Michael Meffie @.***>:

Ah, yes getting the container IP address is the sticking point. The only method I was able to find required running the pvesh command on the proxmox host. If there is no API for such, we are kind of stuck.


From: IamLunchbox @.***> Sent: Wednesday, September 25, 2024 1:10 AM To: meffie/molecule-proxmox Cc: Michael Meffie; Assign Subject: Re: [meffie/molecule-proxmox] [Feature Request] LXC support (Issue #21)

Sure, all contributions are welcome! I think if you would point out differences to the kvm creation that would be helpful.

And maybe you can take the create.yml playbook from this repo as a template and change it to create a lxc container - thatd be great! Just leave out the templating for the start, a smal POC probably helps most to decide if it is feasible.

The biggest problem right now is to determine the ip address of the container. We use the guest agent and a custom module for that, what can we use to reliably find the containers ip through API calls?

Sep 24, 2024 10:48:28 JL Euler @.***>:

I've recently read into the API a bit and worked on the proxmox ansible module, so if there's anything you need help with let me know.

— Reply to this email directly, view it on GitHub[https://github.com/meffie/molecule-proxmox/issues/21#issuecomment-2370656747], or unsubscribe[https://github.com/notifications/unsubscribe-auth/ANRA34KFODDU3QAIRNGE3ZLZYERNVAVCNFSM6AAAAABOQFEVEOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGNZQGY2TMNZUG4]. You are receiving this because you commented. [Tracking image][https://github.com/notifications/beacon/ANRA34ILG45EVQZLSAWPOZ3ZYERNVA5CNFSM6AAAAABOQFEVEOWGG33NNVSW45C7OR4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3TUL5UWJTUNJVM6W.gif]

— Reply to this email directly, view it on GitHubhttps://github.com/meffie/molecule-proxmox/issues/21#issuecomment-2373032147, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AAIPBUSPHYKXEEAROAPCLSTZYJAU3AVCNFSM6AAAAABOQFEVEOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGNZTGAZTEMJUG4. You are receiving this because you were assigned.Message ID: @.***>

— Reply to this email directly, view it on GitHub[https://github.com/meffie/molecule-proxmox/issues/21#issuecomment-2374106076], or unsubscribe[https://github.com/notifications/unsubscribe-auth/ANRA34OXHYS6D3NYRW7COHTZYK3XXAVCNFSM6AAAAABOQFEVEOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGNZUGEYDMMBXGY]. You are receiving this because you commented. [Tracking image][https://github.com/notifications/beacon/ANRA34INOKXSBGWY4ZFXCLLZYK3XXA5CNFSM6AAAAABOQFEVEOWGG33NNVSW45C7OR4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3TUL5UWJTUNQH55Y.gif]

Lithimlin commented 1 month ago

Generally speaking, the Proxmox API allows you to easily get any configured IPs. I suppose with pvesh, you'd get just that path or the .../{vmid}/config?

As far as I can see from the docs and code, the Proxmox module does not return any info on the LXC. The proxmox_vm_info module seems to get a lot of info on a VM (QEMU or LXC), but at first glance this doesn't include the IP address(es). which also includes the IP address(es)

IamLunchbox commented 1 month ago

I could not review the output of proxmox_vm_info for lxc yet, but it seems you are right - at least the api spec supports ips for lxc containers and is used by the module. I dont knwo

So we could possibly substitute the custom qemu guest agent query module when lxc containers are managed.

IamLunchbox commented 1 month ago

@meffie I checked the output of proxmox_kvm. Making lxc containers possible would require us adding a different approach to the current detection method: Setting the ip_address manually as in cloud init right now and then parsing from proxmox_kvm_info.

IMHO this is a nice addition, since it would lead to an alternative detection method besides the qemu guest agent.