vtsingaras / xenorchestra_inventory

Ansible dynamic inventory source for Xen Orchestra (https://xen-orchestra.com/).
GNU General Public License v3.0
1 stars 0 forks source link

Install

This dynamic inventory script requires Python 3. It will NOT work with Python 2.

Usage

To use with ansible just specify the script as the inventory file.
Example:

ansible -i /etc/ansible/xenorchestra.py -m ping all


The inventory script reads its configuration from an ini file with the same name as the script next to the script.
If you decide to place xenorchestra.py elsewhere you must make sure that there's an ini file next to it.

The script will read each VM's tags and make them into the corresponding ansible variables.
With this you can do things like having as vm names non-resolvable names and overriding the ansible_host variable via a XenOrchestra tag:

ansible_host=172.16.1.1


The script will try to autodetect the correct ansible_host variable if there is no such tag by parsing all XenTools-reported IP addresses and using the first one that belongs to a management network.
The management_networks variable is defined the xenorchestra.ini file like so:

management_networks = [ "172.16.0.0/16", "192.168.1.0/24" ]

You can also exclude VMs from being inventoried by setting the deny_tags and/or deny_regex variables like so:

deny_tags = ["Disaster Recovery"]
deny_regex = ["^dev-.*"]

This would exclude all VMs that have either the Disaster Recovery tag or their name starts with "dev-".

Authentication

To use the script you must specify the XenOrchestra server's address:

host = xoa.example.com

and login credentials. You can either use email/password:

email = readeruser
password = readerpassword

or a token:

token = myreaderuserstokenthatigotusingtheapiorxocli

Reporting bugs

Either open an issue or mail me at vyronas at vtsingaras dot me