feat: add incus/LXC connector
Dear pyinfra,
I started adding a LinuxContainers / Incus connector. It is much a work in progress and I would appreciate feedback.
Actually it can:
- work with local or remote incus/lxc server
- execute action on all instances of the targeted incus/lxc server
It relies on the agent to be running on the targeted instance, when not the case it won't be able to do much more than getting it's name from the list and it's IPv4 address if there is one.
Examples:
# on remote servers:
pyinfra @incus/incus.example.net:instance_name files.get src=/tmp/n.log dest=n.log
pyinfra --debug -vvv --dry @incus/incus.example.net: fact server.LinuxName
# same, but target the local server
pyinfra @incus/instance_name files.get src=/tmp/n.log dest=n.log
pyinfra --debug -vvv --dry @incus/ fact server.LinuxName
Obviously I did my code without looking around... Refs: #677, #1282
Hi @romain-dartigues! Thank you for PR-ing this, it's great to see the connector API being used more and more!
As with the PRs linked above I'm not going to merge this into pyinfra core, however, because I would like to reduce the number of connectors that are maintained within pyinfra itself (I am thinking v4 will only contain @ssh and @docker and will move all others into their own packages).
It probably makes most sense to merge any improvements on https://github.com/opekar/pyinfra-connector-lxcssh there to avoid furhter duplicate effort.
Dear @Fizzadar, thank you for your message! I didn't want to put too much effort if there were no interest from the community.
Could we have an "official" way to propose/reference connectors, examples, etc. maybe like how https://github.com/sphinx-contrib/ is doing.
Also, regarding connectors, I'd like to ask you to please think of an easier way to "plug" them (for Pyinfra 4 maybe?).
It is so "simple" to run pyinfra remote.example.net my/tasks.py it feel disappointing the way it is currently done...
Available to talk about potential design on IRC or here.
Could we have an "official" way to propose/reference connectors, examples, etc. maybe like how https://github.com/sphinx-contrib/ is doing.
I'd be up for that, even on this org tbh. If I was to create a pyinfra-dev/pyinfra-lxc-connector would you be interested in owning primary maintenance of that?
Also, regarding connectors, I'd like to ask you to please think of an easier way to "plug" them (for Pyinfra 4 maybe?). It is so "simple" to run
pyinfra remote.example.net my/tasks.pyit feel disappointing the way it is currently done... Available to talk about potential design on IRC or here.
100% agree, though I'm not sure on the best approach. Technically @ssh/HOSTNAME is valid too, we just fallback to SSH when no @ is included. I wonder how we might automatically pick/detect the target connector 🤔
@romain-dartigues @Fizzadar I'm a bit confused here. Where can I find most recent code for this? Maybe I can help. Thanks.