Skip to main content

Proxmox VM & container inventory CLI

Project description

pxinv

A fast CLI for inventorying and managing VMs and containers on your Proxmox homelab.

pxinv demo

$ pxinv list

 VMID  NAME             NODE    TYPE  STATUS   CPU    RAM              DISK             UPTIME  TAGS
──────────────────────────────────────────────────────────────────────────────────────────────────────
 100   homeassistant    pve-01  VM    running  5.2%   1.0GB/4.0GB      10.0GB/32.0GB    3d      homelab
 101   pihole           pve-01  CT    running  0.8%   128.0MB/512.0MB  1.0GB/8.0GB      14d     dns
 200   talos-cp-01      pve-02  VM    stopped  —      —/8.0GB          —/64.0GB         —       k8s

3 resource(s) — 2 running, 1 stopped

Installation

pip install pxinv

Or install from source:

git clone https://github.com/thetechiejourney/pxinv
cd pxinv
pip install -e .

Authentication

pxinv uses Proxmox API tokens (recommended over username/password).

Create a token in Proxmox:

  1. Go to Datacenter → Permissions → API Tokens
  2. Add a token for your user (e.g. root@pam, token name: pxinv)
  3. Copy the token value — it's only shown once

Required permissions: VM.Audit and Sys.Audit on / (or per-node).

Configuration

Credentials can be provided in three ways (in order of precedence):

1. CLI flags

pxinv --host 192.168.1.10 --token-name pxinv --token-value <secret> list

2. Environment variables

export PXINV_HOST=192.168.1.10
export PXINV_TOKEN_NAME=pxinv
export PXINV_TOKEN_VALUE=<secret>
export PXINV_VERIFY_SSL=false   # optional, for self-signed certs

pxinv list

3. Config file

Single host — ~/.config/pxinv/config.yaml:

host: 192.168.1.10
user: root@pam
token_name: pxinv
token_value: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
verify_ssl: false

Multiple clusters — ~/.config/pxinv/config.yaml:

clusters:
  home:
    host: 192.168.1.10
    user: root@pam
    token_name: pxinv
    token_value: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
    verify_ssl: false

  vps:
    host: 95.216.x.x
    token_name: pxinv
    token_value: yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy
    verify_ssl: true

Commands

pxinv clusters

List all configured clusters.

pxinv clusters

pxinv list

List all VMs and containers.

# All guests across all clusters
pxinv list

# Only a specific cluster
pxinv --cluster home list

# Filter by node, type, status or tag
pxinv list --node pve-01
pxinv list --type ct --status running
pxinv list --tags k8s
pxinv list --tags homelab --status running

# JSON output (pipe to jq, etc.)
pxinv list --output json | jq '.[] | select(.cpu_usage > 50)'

# YAML output
pxinv list --output yaml

When multiple clusters are configured, a CLUSTER column appears automatically.

pxinv watch

Live-refresh the VM/container list directly in the terminal. No flickering — powered by rich.Live. Press Ctrl+C to exit.

# Refresh every 5 seconds (default)
pxinv watch

# Custom interval
pxinv watch --interval 10

# Combinable with all list filters and --cluster
pxinv --cluster home watch --status running
pxinv watch --tags k8s --interval 3

The panel header shows the refresh interval and the timestamp of the last update.

pxinv summary

Show cluster-wide resource totals and node status.

pxinv summary
pxinv --cluster vps summary --output json

pxinv start <vmid>

Start a VM or container by VMID.

pxinv start 100

# Wait until the VM is fully running before returning
pxinv start 100 --wait

# Custom timeout (default: 60s)
pxinv start 100 --wait --timeout 120

pxinv stop <vmid>

Gracefully shut down a VM or container by VMID.

pxinv stop 100

# Wait until the VM is fully stopped before returning
pxinv stop 100 --wait

pxinv ansible-inventory

Export the inventory in Ansible dynamic inventory JSON format. Hosts are automatically grouped by status (running, stopped), by Proxmox tag (tag_homelab, tag_k8s, etc.) and by cluster (cluster_home, cluster_vps, etc.).

# Basic inventory (no IPs)
pxinv ansible-inventory

# Fetch IPs via QEMU guest agent (requires qemu-guest-agent installed in VMs)
pxinv ansible-inventory --with-ips

# Only include running guests
pxinv ansible-inventory --running-only

# Use directly with ansible
ansible -i <(pxinv ansible-inventory) all -m ping

# Target a specific group
ansible -i <(pxinv ansible-inventory) tag_homelab -m ping
ansible -i <(pxinv ansible-inventory) cluster_home -m ping
ansible -i <(pxinv ansible-inventory) running -m setup

Example output:

{
  "all": {
    "hosts": ["homeassistant", "pihole"],
    "children": ["running", "stopped", "cluster_home", "tag_homelab", "tag_dns"]
  },
  "running": { "hosts": ["homeassistant", "pihole"] },
  "cluster_home": { "hosts": ["homeassistant", "pihole"] },
  "tag_homelab": { "hosts": ["homeassistant"] },
  "tag_dns": { "hosts": ["pihole"] },
  "_meta": {
    "hostvars": {
      "homeassistant": {
        "ansible_host": "192.168.1.100",
        "proxmox_vmid": 100,
        "proxmox_node": "pve-01",
        "proxmox_type": "vm",
        "proxmox_status": "running",
        "proxmox_cluster": "home",
        "proxmox_tags": ["homelab"]
      }
    }
  }
}

ansible_host is only populated when using --with-ips and the VM has qemu-guest-agent running.

Tags

Proxmox supports tagging VMs and containers via the UI (VM → Options → Tags). pxinv shows tags as a column in pxinv list and lets you filter by them:

pxinv list --tags homelab
pxinv list --tags k8s --status running

Tag matching is case-insensitive. Multiple tags per VM are supported — filtering matches any VM that contains the specified tag.

Self-signed certificates

If your Proxmox uses the default self-signed cert, disable verification:

pxinv --no-verify-ssl list
# or
export PXINV_VERIFY_SSL=false

Contributing

PRs welcome. To set up a dev environment:

git clone https://github.com/thetechiejourney/pxinv
cd pxinv
python3 -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]"
pytest

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pxinv-1.0.0.tar.gz (15.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pxinv-1.0.0-py3-none-any.whl (12.3 kB view details)

Uploaded Python 3

File details

Details for the file pxinv-1.0.0.tar.gz.

File metadata

  • Download URL: pxinv-1.0.0.tar.gz
  • Upload date:
  • Size: 15.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for pxinv-1.0.0.tar.gz
Algorithm Hash digest
SHA256 19c577e5170bb80747fc0423fbba1e839515f8abe2219e435732c5b422c58e04
MD5 cd1e55521d049357c4d03b6f35e15def
BLAKE2b-256 10b1f35bb4631f38e903bea816100d33037ce765f0c0a63770cd422a3068a9ed

See more details on using hashes here.

File details

Details for the file pxinv-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: pxinv-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 12.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for pxinv-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b833bc1a67e08cb18e2984e8125162a5bde65d686b00405e87a845efb8d380a3
MD5 f0bfe31d601ec632eb071dee89bd7610
BLAKE2b-256 275636556aa9bea5f9c19166f607e1aba2026eb0a4239cfcc5961e52eacb9898

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page