Ansible simplified yaml inventory
Project description
Ansible Roster Plugin
This repository contains an Ansible inventory plugin to generate inventory from a subjectively simpler inventory description file while having more possibilities.
Installation
Install latest version:
python3 -mpip install --pre -U ansible-roster
Features
-
Subjectively simpler syntax
-
Tags that behave like groups but that do not create groups.
-
Ranges and Regex support:
sql-[0:9].example.com
,(front|back)end-[0:9].example.com
Usage
'Roster' inventory file
The roster inventory file is a typical yaml file.
A sample, commented, file named 'roster.yml.tpl' is located at the root of the git repository.
In order for ansible to use the plugin and parse your roster file, several conditions must be met.
-
Your yaml file must contain a line indicating that the file is in the roster format.
-
You must activate plugins and enable the roster inventory plugin in your ansible.cfg
Sample roster.yml
---
plugin: roster
hosts:
localhost
Sample edited ansible.cfg
[defaults]
# The following line prevents having to pass -i to ansible-inventory.
# Filename can be anything as long as it has a 'yml' or 'yaml' extension although
# the plugin will directly accept any file named 'roster.yml'.
inventory = roster.yml
# Append or edit the 'inventory_plugins' line to add the path the
# ansible_roster/plugins package located in your versionned Python site-packages path.
inventory_plugins = ~/.local/lib/python3.7/site-packages/ansible_roster/plugins
[inventory]
# You must enable the roster plugin if 'auto' does not work for you
enable_plugins = roster
Verify that the plugin is correctly found:
ansible-inventory --graph
Development
To run unit tests, you can simply run the make target:
# run all tests:
make check
It's also possible to quickly check the output inventory:
export PYTHONPATH="$PYTHONPATH:$(pwd)"
ANSIBLE_INVENTORY_ENABLED=roster ANSIBLE_INVENTORY_PLUGINS="$(pwd)/ansible_roster/plugins/inventory" ansible-inventory --list -i roster.yml
License
This project is licensed under the MIT License - see the LICENSE file for details
Locations
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
Built Distribution
Hashes for ansible_roster-0.1.8-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0c92cf80c6e3e294474a867b81f94951a74e15cf75de1eb58e014d6574320ba6 |
|
MD5 | 2f9c7cabd1605f63fa754666d9836662 |
|
BLAKE2b-256 | d9735fe5ab48649e8439c88b71ef3f87402695299ee7fae16e89c5e35a072092 |