All Projects → iautom8things → Ansible Meta Dynamic Inventory

iautom8things / Ansible Meta Dynamic Inventory

Licence: mit
Naming is hard. This wrapper script allows you to use set notation with dynamic host groups.

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Ansible Meta Dynamic Inventory

Awless
A Mighty CLI for AWS
Stars: ✭ 4,821 (+19987.5%)
Mutual labels:  aws, devops, devops-tools
Terracognita
Reads from existing Cloud Providers (reverse Terraform) and generates your infrastructure as code on Terraform configuration
Stars: ✭ 452 (+1783.33%)
Mutual labels:  aws, devops, devops-tools
Pytest Testinfra
With Testinfra you can write unit tests in Python to test actual state of your servers configured by management tools like Salt, Ansible, Puppet, Chef and so on.
Stars: ✭ 1,987 (+8179.17%)
Mutual labels:  ansible, devops, devops-tools
Ansible Podman Collections
Repository for Ansible content that can include playbooks, roles, modules, and plugins for use with the Podman tool
Stars: ✭ 89 (+270.83%)
Mutual labels:  ansible, devops, devops-tools
Aws Toolbox
A collection of DevOps tools including shell & python scripts that automate the boring stuff in AWS.
Stars: ✭ 89 (+270.83%)
Mutual labels:  aws, devops, devops-tools
Ansible For Devops
Ansible for DevOps examples.
Stars: ✭ 5,265 (+21837.5%)
Mutual labels:  aws, ansible, devops
Awless Templates
Repository of examples for awless templates (see https://github.com/wallix/awless)
Stars: ✭ 59 (+145.83%)
Mutual labels:  aws, devops, devops-tools
Serverfarmer
Manage multiple servers with different operating systems, configurations, requirements etc. for many separate customers in an outsourcing model.
Stars: ✭ 122 (+408.33%)
Mutual labels:  ansible, devops, devops-tools
Awstaghelper
AWS bulk tagging tool
Stars: ✭ 98 (+308.33%)
Mutual labels:  aws, devops, devops-tools
Terraboard
🌍 📋 A web dashboard to inspect Terraform States
Stars: ✭ 1,192 (+4866.67%)
Mutual labels:  aws, devops, devops-tools
Azure
Azure-related repository
Stars: ✭ 78 (+225%)
Mutual labels:  ansible, devops, devops-tools
Rundeck
Enable Self-Service Operations: Give specific users access to your existing tools, services, and scripts
Stars: ✭ 4,426 (+18341.67%)
Mutual labels:  ansible, devops, devops-tools
Devops Exercises
Linux, Jenkins, AWS, SRE, Prometheus, Docker, Python, Ansible, Git, Kubernetes, Terraform, OpenStack, SQL, NoSQL, Azure, GCP, DNS, Elastic, Network, Virtualization. DevOps Interview Questions
Stars: ✭ 20,905 (+87004.17%)
Mutual labels:  aws, ansible, devops
Ansible Playbook
Ansible playbook to deploy distributed technologies
Stars: ✭ 61 (+154.17%)
Mutual labels:  aws, ansible, devops
Learn Devops
🚧 Learn the craft of "DevOps" (Developer Operations) to Deploy your App and Monitor it so it stays "Up"!
Stars: ✭ 139 (+479.17%)
Mutual labels:  aws, devops, devops-tools
Opscloud
运维管理平台(阿里云),自动同步阿里云配置信息,堡垒机(容器),批量运维,Kubernetes,Zabbix管理等功能
Stars: ✭ 788 (+3183.33%)
Mutual labels:  aws, ansible, devops
Gaia
Build powerful pipelines in any programming language.
Stars: ✭ 4,534 (+18791.67%)
Mutual labels:  devops, devops-tools
Goss
Quick and Easy server testing/validation
Stars: ✭ 4,550 (+18858.33%)
Mutual labels:  devops, devops-tools
Org Formation Cli
Better than landingzones!
Stars: ✭ 471 (+1862.5%)
Mutual labels:  aws, devops
Awesome Open Source Supporters
⭐️ A curated list of companies that offer their services for free to Open Source projects
Stars: ✭ 457 (+1804.17%)
Mutual labels:  devops, devops-tools

ansible-meta-dynamic-inventory

This script takes, as input, the output of a dynamic inventory script and reads in another file, called a Groupsfile, that allows the creation of new groups using any of Ansible's Pattern set notations, and then outputs an updated version of the dynamic inventory that it received.

Who does this help?

Anyone that extensively uses Ansible Patterns.

What does this give you?

  1. The ability to effectively alias your patterns, by creating new groups from your patterns.
  2. The ability to define group_vars for your patterned groups.
  3. A single source for defining your patterned groups.
  4. More reusable playbooks.

Dependancies

  • Python (developed against 2.7.12)
  • Parsley v1.3 [link]

Introduction

Ansible has a concept of Inventory, this is your listing/groupings of all of the machines in your infrastructure. Ansible allows for two types of inventories: static and dynamic.

Here is an example of a simple static inventory:

[web]
10.0.1.2
10.0.1.3

[db]
10.2.0.2
10.2.0.3

[aws_us_east]

[aws_us_east:children]
web
db

This static inventory file describes two groups (web,db) with two hosts each, and a third group (aws_us_east) that is the union of web and db. Static inventory works great if you have very few machines that never change, and it becomes virtually useless with the more hosts you have or the more dynamic your inventory is.

Dynamic inventory to the rescue!

Dynamic inventory is an executable script that inspects your infrastructure and dynamically creates groups out of them. If you're on AWS and using Ansible, then you're likely familiar with ec2.py [link], a Python script that uses your AWS credentials to inspect EC2 and dynamically create groups based on VPCs, security groups, tags and much more.

Ansible Patterns

Ansible also has this great feature that allows you to use set functions like union, intersection and difference on your host groups, called Patterns [link]. This allows for you to home in on just the right group of hosts to operate on.

Examples:

  • Union (All API and WEB nodes)

      tag_Product_api:tag_Product_web
    
  • Intersection (Production API nodes)

      tag_Product_api:&tag_Env_prod
    
  • Difference (Non-API nodes)

      tag_Product_api:!tag_Env_prod
    
  • Slicing (The first two nodes with tag Product=api)

      tag_Product_api[0:2]
    

See the Ansible documentation for a complete list of possible patterns.

The Rub

Ansible Patterns are limited to being used on the command line:

$ ansible tag_Env_prod:&tag_Service_web -m service -a "name=httpd state=restarted"

Or they can be used as the host specifier for a play:

---
- name: Install SomeService Role
  hosts: tag_Env_stg:!tag_Service_elk
  become: yes

  roles:
    - SomeService

This means that you cannot use patterns in a static inventory file. So the following does not work:

[web]
5.5.5.5
10.10.10.10

[prod]
10.10.10.10

[web_prod]

[web_prod:children]
web:&prod

This static inventory file attempts to create a web_prod group that only consists of machines in both web && prod.

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].