Pyventory
Ansible Inventory implementation that uses Python syntax
Install
pip3 install pyventory
Features
- Modular inventory.
- Assests inheritance using Python classes.
- Support for multiple inheritance.
- Support for mixins.
- Support for vars templating using Python string formatting.
- Python 3 (>=3.6) support.
- Python 2 is not supported.
Usage
Create hosts.py and make it executable.
A short example of the hosts.py contents:
#!/usr/bin/env python3
from pyventory import Asset, ansible_inventory
class All(Asset):
run_tests = False
use_redis = False
redis_host = 'localhost'
minify = False
version = 'develop'
class Staging(All):
run_tests = True
staging = Staging()
ansible_inventory(locals())
Consider a more complex example which passes the following json output to Ansible.
Run Ansible playbook with the -i hosts.py key:
ansible-playbook -i hosts.py site.yml
Notice that you need to have your inventory package in PYTHONPATH.
Metadata
Release files for pyventory 3.3.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pyventory-3.3.2.tar.gz | 5.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pyventory-3.3.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 12.6 kB
Release files / pyventory-3.3.2.tar.gz
| Download URL | pyventory-3.3.2.tar.gz |
|---|---|
| Size | 5.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8ebae89abb21a7fa953e86dd9bd2c3f1f714021effdcf1d03cfe882f89389e4c
|
|
BLAKE2b-256 checksum How to use checksums |
8ddf4580ec217c593a9150e1a2b4ab0ac7cf809233843e5166e4ec55b15e4d06
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.2.2 CPython/3.10.7 Linux/5.19.14-200.fc36.x86_64
|
Release files / pyventory-3.3.2-py3-none-any.whl
| Download URL | pyventory-3.3.2-py3-none-any.whl |
|---|---|
| Size | 6.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a376f1ab6d98624d3107b31ada573bf386e056c193aeed1c7b027d1a8b279dc5
|
|
BLAKE2b-256 checksum How to use checksums |
919c6588e6fc385d7754bfcf5d90477f4de32f6f478e42efad1f5d9ef38027a8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.2.2 CPython/3.10.7 Linux/5.19.14-200.fc36.x86_64
|