Ansible allows for using dynamic inventory, this inventory can be a simple python script.
- No extra dependencies are needed besides those specified in
pyproject.toml
.poetry install
installs the deps. - Configure the credentials in
proxmox.json
. - An example ansible inventory can be found here:
ansible-example/inventory/proxmox.py
, edit theproject_filters
andFetchPublicIPAddress
function (Reason described below). - The dynamic inventory can be generated then with
ansible-inventory -i <PATH>/inventory/proxmox.py --list
. - Test ping with
ansible -i <PATH>/inventory/proxmox.py -m ping all
- Run an example ansible-playbook to confirm that you can reach the VMs and run playbooks against them.
Note:
While the inventory queries the public API endpoint, the ansible scripts are run on the VMs themselves. These VMs
will only return a private subnet IP
and our system will not have a path to it. Which is why we need to use
the jump host method of connecting to the VMs. Make sure that you have SSH access(ideally via key) via USERNAME@PROXMOX-HOST-IP
.
TL;DR: All the traffic will essentially "jump" through the proxmox host to the VM you want to interact with