Proxmox inventory plugin. Based on original plugin from Mathieu Gauthier-Lafaye and updated plugin by Xabi Ezpeleta and another updated plugin by RaSerge
installed qemu-guest-agent on Proxmox vm's
- Removed ansible lib requirements
- Requests instead of urllib
- Qemu interfaces ip detection: You should have qemu-guest-agent installed and activated
- ProxmoxVE cluster: if your have a ProxmoxVE cluster, it will gather the whole VM list from your cluster
- Advanced filtering: you can filter the VM list based in their status or a custom tag included in the
Notes
field
Clone this repository into "inventory_plugins" dir relative to your playbook:
git clone https://github.com/bkmeneguello/ansible-proxmox-inventory.git inventory_plugins/proxmox
Add some configurations to your "ansible.cfg":
[defaults]
inventory_plugins=./inventory_plugins
[inventory]
enable_plugins = proxmox
Create an inventory file with "proxmox.yml" suffix:
plugin: proxmox
url: https://pve.example.com:8006
username: root
password: password
Let's test it:
ansible-inventory -i inventory.proxmox.yml --list
If you get a list with all the VM in your Proxmox cluster, everything is ok.
you can include the dynamic inventory in your ansible commands:
# Ping: connect to all VM in Proxmox using root user
ansible -i inventory.proxmox.yml all -m ping -u root
#$ Added support for using the Notes field of a VM to define groups and variables:
Any YAML document starting with "---" anywhere in Notes field will be parsed an if contains an "ansible_groups" entry the host will be added to these groups. If it conains an "ansible_variables" entry they will be added to the host vars:
For instance, you can use the following text code in a VM host notes:
Lorem Ipsum ...
---
ansible_groups:
- windows
ansible_variables:
ansible_user: Administrator
So if you want to exclude Windows machines, you could do the following:
# Run a playbook in every running Linux machine in Proxmox
ansible-playbook -i inventory.proxmox.yml --limit='running,!windows' playbook-example/playbook.yml