Select available PVE node for Ansible api node

isarjoe

New Member
Nov 5, 2025
1
0
1
Hi community,
pretty new to Proxmox with Ansible and have a few questions:

First of all, I'm unsure if I use the collection community.proxmox correctly. I want to use the API using API tokens (which work).
So I guess I need to delegate my proxmox tasks to `localhost`. Otherwise, the Ansible control node tries to connect to the inventory host (e.g. the Proxmox node) via SSH and issue the REST command there. Example:
YAML:
- name: "Check PVE nodes"
  community.proxmox.proxmox_node_info:
    api_host: pve1.local
  delegate_to: localhost

My strategy is, to use my target VMs I want to deploy as Ansible play targets.

My second question is: Is there an elegant way to detect which PVE node to use as api_hostin the tasks? For example, my Datacenter consists of three nodes.
I could choose the first one as api_host, but what if this one is not available (e.g. maintenance)? I want Ansible to use the "first available" PVE node.
Playing around with looping over all PVE nodes and checking the node info using community.proxmox.proxmox_node_info
However I'm wondering, if there is an easy, builtin way?