Giter Site home page Giter Site logo

proxmox-inventory-plugin's Introduction

Proxmox inventory source CI

Version on Galaxy

An ansible plugin to source inventory from a Proxmox Cluster.

Installation

ansible-galaxy install mrsuicideparrot.proxmox_plugin

Similar projects

xezpeleta/Ansible-Proxmox-inventory is an inventory script. It offers definition of custom variables using Proxmox notes. However, ansible is deprecating inventory scripts. The new recomended way is to create an inventory plugin and package it as an Ansible Collection.

ansible-collections/community.general is an Ansible Collection that has an inventory plugin for Proxmox. This plugin doesn't support custom variables.

How to use it

If you want to use this plugin in your project, you first need to install it. Then, you need to create a new inventory. The file name needs to end with proxmox.yaml, for example my.proxmox.yaml.

The inventory must have the following content, filled with the appropriate credentials:

plugin: "mrsuicideparrot.proxmox_plugin.inventory"
url: https://localhost:8006
user: apiuser@pve
password: secure
validate_certs: True
group_tags: False

You should create a user with least privileges possible. You need the following privileges: VM.Audit, VM.Monitor, SDN.Audit, Sys.Audit, Pool.Audit, Datastore.Audit. For now, we don't support Proxmox API tokens, only passwords.

Finally, you activate the plugin by creating a galaxy.cfg in the repo directory.

[inventory]
enable_plugins = mrsuicideparrot.proxmox_plugin.inventory

You are now ready to source dynamically an inventory from your Proxmox Cluster.

You can check if everything is working by listing the inventory.

ansible-inventory --list -i my.proxmox.yml

You should see a list of nodes from your Proxmox Cluster.

Custom metadata

You can use the notes field in your Proxmox server to define variables. To leverage this feature, the notes should be a valid JSON.

This feature can also be used to assign groups to a machine.

{ "groups": ["windows", "utils"] }

If the VM has the qemu guest agent working or ,in the case of a container, it has a static IP configured, the variable ansible_host will be defined with the IP address of the machine.

A definition of multiple variables would be:

{ "groups": ["docker", "server"], "ansible_user":"root", "custom_variable":"things" }

Furthermore, if you enable group_tags you can use the tags you define for each virtual guest as ansible groups.

This feature requires at least Proxmox VE 7.3.

Requirements

None


Acknowledgments

This project was based on xezpeleta/Ansible-Proxmox-inventory.

proxmox-inventory-plugin's People

Contributors

ch0wm3in avatar mrsuicideparrot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

ch0wm3in

proxmox-inventory-plugin's Issues

Support for proxmox 8?

It doesn't seem to be functioning properly. Do we have any information if it is compatible with Proxmox v8?

ansible-inventory --list -i my.proxmox.yml 
[WARNING]: Unable to parse /home/linux/ansible/stackblaze/my.proxmox.yml as an inventory source
[WARNING]: No inventory was parsed, only implicit localhost is available
{
    "_meta": {
        "hostvars": {}
    },
    "all": {
        "children": [
            "ungrouped"
        ]
    }
}

My versions here:

Proxmox version:  8.0.3 
ansible [core 2.14.6]
  python version = 3.10.6 (main, May 29 2023, 11:10:38) [GCC 11.3.0] (/usr/bin/python3)
  jinja version = 3.0.3
  libyaml = True

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.