Ansible direct connection to containers using PVE as a proxy

Oct 10, 2022
48
2
13
I'm using Ansible to connect to containers and VM's via SSH, but I'm wondering if there is a better way to do it using PVE as a proxy, given there are tools such as pct exec, pct enter, and pct console that allow Proxmox to send commands directly to the containers. This would allow to connect to containers which Ansible cannot reach via the network.

Meanwhile I've found Ansible lxc_container module, but I'm having issues installing the needed package python3-lxc, as I've described in this forum thread.

Is there a better way to use PVE as proxy to any container for task automation?

I don't think pct exec and the related commands are ideal, as they will not handle errors via the Ansible API, but by now they seem to be the best option (if I can get them to work somehow with Ansible)
 
That's interesting, I was not aware.

My question is if there is any tool (maybe an Ansible module or a different tool) that could help automating tasks by connecting to nodes using the PVE node as a proxy without the need of SSH keys and the hassle of network issues.

Apparently, the Ansible plugins I've found don't have this feature yet.
 
I wrote a connectoion plugin, and combined with the raw module, I realized the direct batch management of lxc on the pve host. As for vn, you can directly use ssh
 
The lxc of pve is modified, so even if python-lxc is installed, it should not be used. If you really want to install it, you can use python venv
 
I wrote a connectoion plugin, and combined with the raw module, I realized the direct batch management of lxc on the pve host. As for vn, you can directly use ssh
I want to write a pct module to replace the raw module, which can execute commands more flexibly