Skip to content

bkmeneguello/ansible-proxmox-inventory

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 

Repository files navigation

Ansible Proxmox Inventory Plugin

About

Proxmox inventory plugin. Based on original plugin from Mathieu Gauthier-Lafaye and updated plugin by Xabi Ezpeleta and another updated plugin by RaSerge

Requirements

installed qemu-guest-agent on Proxmox vm's

Features

  • 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

Instructions

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

About

Refactored ansible proxmox inventory script.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages

  • Python 100.0%