howto start and reuse ssh for pre ansible python provisioning script

Making a script that setups guest machines on proxmox, then gives inventory to ansible. The problem is everything is done with a call to subprocess.check_output … ‘ssh {proxmoxhost} …’ its been solid, but also seems kinda silly to go through all that.

ControlPath helps, but id rather just open one ssh connection and use that throughout the script. ive seen solutions like paramiko and pexpect, but id like to read about your experiences to save some mistakes

the other option i was thinking of was having the script put itself and the input files on the remote host and just run from there. kinda like what ansible does.