All Projects → leboncoin → simple-ansible-inventory

leboncoin / simple-ansible-inventory

Licence: MIT license
A simple, clean and easily readable Ansible inventory

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to simple-ansible-inventory

Ocsinventory Server
Communication server of OCS Inventory
Stars: ✭ 214 (+756%)
Mutual labels:  inventory
ansibleconnect
Connect to all hosts from the inventory with one command
Stars: ✭ 25 (+0%)
Mutual labels:  inventory
ymlx
Command-line YAML processor
Stars: ✭ 77 (+208%)
Mutual labels:  yml
Storaji
📒 The light/responsive inventory management system available on Windows, macOS and Linux.
Stars: ✭ 222 (+788%)
Mutual labels:  inventory
Fusioninventory For Glpi
FusionInventory plugin for GLPI
Stars: ✭ 241 (+864%)
Mutual labels:  inventory
api-spec
API Specififications
Stars: ✭ 30 (+20%)
Mutual labels:  yml
Aws Recon
Multi-threaded AWS inventory collection tool with a focus on security-relevant resources and metadata.
Stars: ✭ 203 (+712%)
Mutual labels:  inventory
php-serializer
Serialize PHP variables, including objects, in any format. Support to unserialize it too.
Stars: ✭ 47 (+88%)
Mutual labels:  yml
Xtuple
This repository contains the source code for the database schema for the PostBooks edition of xTuple ERP and xTuple's REST API server. The REST API server is written in JavaScript running on Node.js. The database schema for PostBooks runs on a PostgreSQL database server.
Stars: ✭ 247 (+888%)
Mutual labels:  inventory
Binner
Open source parts inventory system for makers, electronics hobby, and professional engineers
Stars: ✭ 122 (+388%)
Mutual labels:  inventory
Ledgersmb
Repository for the LedgerSMB project -- web app for accounting & ERP
Stars: ✭ 222 (+788%)
Mutual labels:  inventory
Warehouse Inventory System
Open source inventory management system with php and mysql
Stars: ✭ 235 (+840%)
Mutual labels:  inventory
POS---Point-Of-Sales
Point of sales proof of concept developed using Asp.Net Core 2.2. Features: Customer, Vendor, Product, Purchase Order, Goods Receive, Sales Order, Inventory Transactions and POS form.
Stars: ✭ 120 (+380%)
Mutual labels:  inventory
Tailor made
✄ Managing a Fashion designer's daily routine.
Stars: ✭ 219 (+776%)
Mutual labels:  inventory
PSP-Inventory
Inventorise your environment through PowerShell
Stars: ✭ 28 (+12%)
Mutual labels:  inventory
Defterp
deftERP - Jakarta EE (Java EE 7 : JSF, JPA, EJB, CDI, Bean Validation)
Stars: ✭ 207 (+728%)
Mutual labels:  inventory
bizbook-server
The repository of bizbook server web api project
Stars: ✭ 45 (+80%)
Mutual labels:  inventory
django-graphql-graphene-example
A Django GraphQL API example with Django Graphene
Stars: ✭ 24 (-4%)
Mutual labels:  inventory
publiccode.yml
A metadata standard for public software
Stars: ✭ 97 (+288%)
Mutual labels:  yml
GuiLib
Yet another bukkit inventory gui library
Stars: ✭ 18 (-28%)
Mutual labels:  inventory

Simple Ansible Inventory

The idea is to keep an Ansible inventory simple, clean and easily readable. Each host will only have to be written one time and you'll not have to define each group before using it.

Prerequisites

Simple Ansible Inventory works with python2 and python3. Only the package pyyaml is needed. You can install it using one of the following commands

pip install -r requirements.txt

or

pip install pyyaml

How to use

Alone

./simple-ansible-inventory.py --list

With ansible

ansible-inventory -i simple-ansible-inventory.py --list

To work properly, simple-ansible-inventory.py needs inventory file(s) to read. There's two possibilities :

  • By default, simple-ansible-inventory.py will look in its folder and in all of its subfolder for inventory yaml file(s)
  • If the environment variable ANSIBLE_YAML_INVENTORY is defined, simple-ansible-inventory.py will attempt to read the inventory file in the environment variable and only this one

Directory layout

The directory layout followed is given by the Ansible best pratices. https://docs.ansible.com/ansible/latest/user_guide/playbooks_best_practices.html#directory-layout

Inventory files

You can find inventory file examples in inventory_file_1.yml and inventory_file_2.yml

An inventory file is a yaml file starting with the following header

---
#### YAML inventory file

In this inventory file, you only define hosts and groups associated to this host. There's no group definition, a group is automatically created when associated to an host.

Example:

If you define the following host

hosts:
  - host: luke-01.example.com
    groups: [group_1, datacenter_1]
  • the host luke-01.example.com will be created
  • groups group_1 and datacenter_1 will be created
  • groups group_1 and datacenter_1 will be associated to the host luke-01.example.com

Group vars

Following Ansible best practices, all group vars have to be defined in the group_vars folder. If you want to create the variable group: Rebels for the group group_1, you have to create the file group_vars/group_1.yml with the following content:

---
group: Rebels

Host vars

There's two possibilities to define host vars

  1. In the inventory file
  2. In the host_vars folder (following Ansible best practices)

In the inventory file

If you want to create the variable lightsaber: blue for the host obi-wan-02.example.com, you have to set hostvars for the host in the inventory file:

- host: obi-wan-02.example.com
  hostvars:
    lightsaber: blue
  groups: [group_1, datacenter_1]

In the host_vars folder (following Ansible best practices)

Following Ansible best practices, host vars have to be defined in the host_vars folder. If you want to create the variable force_side: Sith for the host darth-vader-01.example.com, you have to create the file host_vars/darth-vader-01.example.com.yml with the following content:

---
force_side: Sith

And that's it !

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].