Ansible dynamic inventory

Hi @all,

i have developed a dynamic inventory plugin for lxd and looking for testers. The plugin is available on github and i will start cleanup and refactoring in the coming days.

The following filters for groups are currently implemented:
- location: no idea if it works, i grabbed examples from bugreports -> need sample
- pattern: e.g. samba * or regex
- network_range: e.g. 192.168.0.0/24 or fd42: bd00: 7b11: 2167: 216: 3eff :: / 24
- os: e.g. ubuntu
- release: e.g. groovy
- profile: e.g. default
- vlanid: e.g. 666

repo: https://github.com/conloos/community.general
plugin path: plugins/inventory/lxd.py
testdata: plugins/inventory/test/lxd_inventory.atd
ansible config: plugins/inventory/test/lxd.py

For testing, the following structure must be created, i use symlinks:

inventory_plugins/lxd.py -> …/…/ansible-collections/plugins/inventory/lxd.py
inventory_plugins/test -> …/…/ansible-collections/plugins/inventory/test/
lxd.yml -> …/ansible-collections/plugins/inventory/test/lxd.yml

The test is started by the following command:
$ ansible-inventory -i lxd.yml --playbook-dir ./ --list

In the ansible config: “plugins/inventory/test/lxd.py” is by default “selftest: True”, to start a realworld test, please set it to False and adjust the config according to your needs.

Should it fail, please create a dump “dumpdata: true” and upload the file “lxd_data- .atd” and the config.

I am currently primarily interested in the results of the test with clusters and a “location” and “vlanid”.

Greetings Frank

1 Like

Oh, that sounds quite interesting!