Proxmox pct connetion

mietzen
Sat, 25 May 2024 13:25:21 +0000
Get Help

Hi,

wanted to build a connection plugin similar to lxc. It should directly connect into the container on a proxmox host that is not reachable via ssh.

This is my code so far (NOT finished):
https://github.com/mietzen/community.general/blob/add-pct-connection/plugins/connection/pct.py

But I hit some road bumps and I’m not sure if what I want to archive is possible.

What I wanted:

Call a playbook from my Laptop execute it on the proxmox host inside the container using pct exec.

What I got:

My code is trying to run on my Laptop and fails because it can’t find pct.

I read that we can only use one connection per host, so is what I wanted to archive impossible? Or must I warp the ptc connection inside a ssh tunnel?

So something like:

remote_cmd = [
    self._pct_cmd,
    "exec",
    self._vmid(),
    "--",
    self.get_option("executable"), "-c", cmd])


ssh = paramiko.SSHClient()
ssh.load_system_host_keys()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(hostname=host, username=user, pkey=k)
ssh_stdin, ssh_stdout, ssh_stderr = ssh.exec_command(' '.join(remote_cmd))

3 posts - 2 participants