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.1.tar.gz
(5.9 kB
view hashes)
Built Distribution
Close
Hashes for pyventory-3.3.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e9bcb629742fe6b3f4bb57c6f04e4fe696b21d58052af9d7b1959d2bc47f3cce |
|
MD5 | df6fccb874a8274525d2d9e2aa90c7b3 |
|
BLAKE2b-256 | 3548605d697853df00fa75576081c9df1193fb4a2f98e10f23bd65b34bfcbaae |