Skip to content

Conversation

mietzen
Copy link
Contributor

@mietzen mietzen commented Sep 14, 2025

SUMMARY

This connection plugin uses SSH (paramiko) to connect to a Proxmox host and then calls qm to connect to a Proxmox VM.

I mainly based the code on proxmox_pct_remote. I made this a draft since the tests are only copied from proxmox_pct_remote at the moment.

Why is this useful?

After implementing proxmox_pct_remote, I wanted to add the ability to use Ansible in VMs without any network access to the VM itself.

ISSUE TYPE
  • New Module/Plugin Pull Request
COMPONENT NAME

proxmox_qm_remote

ADDITIONAL INFORMATION

Caveats:

  • File transfer is really slow! Only around 90-350 KB/s depending on the server load. I tested it here.
  • Only Linux and FreeBSD VMs are supported.

qm accepts only 1048575 Byte (1 MiB - 1 Byte) of input data, so larger files need to be split into chunks and verified.

qm guest exec <vmid> [<extra-args>] [OPTIONS]
Executes the given command via the guest agent
<vmid>: <integer> (100 - 999999999)
    The (unique) ID of the VM.
<extra-args>: <array>
    Extra arguments as array
--pass-stdin <boolean> (default = 0)
    When set, read STDIN until EOF and forward to guest agent via input data (usually treated as STDIN for the process launched by the guest agent). Allows at most 1 MiB.
--synchronous <boolean> (default = 1)
    If set to off, returns the PID immediately instead of waiting for the command to finish or for the timeout.
--timeout <integer> (0 - N) (default = 30)
    The maximum time to wait synchronously for the command to finish. If reached, the PID is returned. Set to 0 to disable.

Source

Example log output:

<192.168.10.10> PUT /Users/nils/Developer/ansible.community.proxmox/test-playbook/5_MiB_File TO /root/.ansible/tmp/ansible-tmp-1757869572.1343842-62185-232774369890767/.source
File size: 5242880 bytes. Transferring in 6 chunks.
Transferring chunk 1/6 (1048575 bytes)
Transferring chunk 2/6 (1048575 bytes)
Transferring chunk 3/6 (1048575 bytes)
Transferring chunk 4/6 (1048575 bytes)
Transferring chunk 5/6 (1048575 bytes)
Transferring chunk 6/6 (5 bytes)
TODOS
  • Test are only copied over from proxmox_pct_remote and need to be adjusted / fixed
  • Fix integration test

@mietzen mietzen closed this Sep 14, 2025
@mietzen mietzen reopened this Sep 14, 2025
@mietzen mietzen force-pushed the implement-proxmox-qm-remote branch from e3ad716 to 37b7be6 Compare September 15, 2025 08:30
Copy link

codecov bot commented Sep 15, 2025

Codecov Report

❌ Patch coverage is 86.83575% with 109 lines in your changes missing coverage. Please review.
✅ Project coverage is 65.51%. Comparing base (a0f0955) to head (90e3d8b).

Files with missing lines Patch % Lines
plugins/connection/proxmox_qm_remote.py 72.12% 71 Missing and 38 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #188      +/-   ##
==========================================
+ Coverage   62.59%   65.51%   +2.92%     
==========================================
  Files          55       57       +2     
  Lines        6036     6864     +828     
  Branches     1207     1361     +154     
==========================================
+ Hits         3778     4497     +719     
- Misses       2098     2169      +71     
- Partials      160      198      +38     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mietzen mietzen marked this pull request as ready for review September 15, 2025 10:42
@mietzen mietzen changed the title Implement proxmox qm remote connection plugin [WIP] Implement proxmox qm remote connection plugin Sep 16, 2025
@Thulium-Drake Thulium-Drake marked this pull request as draft September 19, 2025 11:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant