Ansible Inventory implementation that uses Python syntax
Project description
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
.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pyventory-3.3.0.tar.gz
(5.9 kB
view details)
Built Distribution
File details
Details for the file pyventory-3.3.0.tar.gz
.
File metadata
- Download URL: pyventory-3.3.0.tar.gz
- Upload date:
- Size: 5.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.2.1 CPython/3.10.7 Linux/5.19.13-200.fc36.x86_64
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e3075e02d8b5e15de33ca9f578dd5a2a446c46702baecd67b8998b2fa9e7427e |
|
MD5 | 17a1eb97188bde5d6a9c3da4685f1cf0 |
|
BLAKE2b-256 | 16e9202a84d8f00355b3dc2bd4b3d542c19846f091365f45ea2ffda2e7874164 |
File details
Details for the file pyventory-3.3.0-py3-none-any.whl
.
File metadata
- Download URL: pyventory-3.3.0-py3-none-any.whl
- Upload date:
- Size: 6.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.2.1 CPython/3.10.7 Linux/5.19.13-200.fc36.x86_64
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 997d358fd11c79525d344a4d56983ffc7c7fd1a4ed97a416841daa9c7597dd60 |
|
MD5 | 8010bd02b2e1d8394f38122f0bbfd93d |
|
BLAKE2b-256 | e10171d02fbac5d575fb8fba01f9b311ed12dd89810ce2ebb02f22f84ade1540 |