Ansible Dynamic Inventory for Proxmox

I’ve been playing with Ansible lately as part of my RHCA studies, and found a nice way of using dynamic inventory to manage my Proxmox homelab.


On the Ansible control node, change to the folder where playbooks are stored:

$ cd /home/ansible/playbooks

Download the script:

$ wget

Make it executable:

$ chmod 0755 ./


Try listing dynamic inventory:

$ ./ \
  --url= \
  [email protected] \
  --password=changeme \
  --list --pretty
  "all": {
    "hosts": [

Create a file with environment variables to store Proxmox credentials:

export [email protected]
export PROXMOX_PASSWORD=changeme

Execute commands from filename in the current shell environment:

$ source ./

List dynamic inventory without passing credentials on the CLI:

$ ./ --list --pretty

Use inventory with Ansible:

$ ansible all -i ./ -m ping -u ansible
ansible5.hl.local | SUCCESS => {
    "changed": false, 
    "ping": "pong"
proxy1.hl.local | SUCCESS => {
    "changed": false, 
    "ping": "pong"

Leave a Reply

Your email address will not be published. Required fields are marked *