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.2.0.tar.gz
(5.9 kB
view details)
Built Distribution
File details
Details for the file pyventory-3.2.0.tar.gz
.
File metadata
- Download URL: pyventory-3.2.0.tar.gz
- Upload date:
- Size: 5.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.0b2 CPython/3.8.5 Linux/5.8.7-200.fc32.x86_64
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8a04996bed57858066a30d0dda4bee57548924fa46627513942c18cef38fbf5e |
|
MD5 | b13e2c3e45e3ad72118e76ce882be44c |
|
BLAKE2b-256 | 3f03ea4f31f7dc5fa44314e169a64f2938319af5e4022d540cb4466d3b9ca9f0 |
File details
Details for the file pyventory-3.2.0-py3-none-any.whl
.
File metadata
- Download URL: pyventory-3.2.0-py3-none-any.whl
- Upload date:
- Size: 6.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.0b2 CPython/3.8.5 Linux/5.8.7-200.fc32.x86_64
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e868509e9675b1fb26717db8cf0a51908b4bb1587405d1a85dd8430dbc921878 |
|
MD5 | 2009054ddb87b0b11be63186c3c8edf9 |
|
BLAKE2b-256 | 5f9e678432b240ce42429e6a632f877bda01447d34298e03e60fe9153ab5954f |