GithubHelp home page GithubHelp logo

ansible-dyninv-mysql's Introduction

Ansible Dynamic Inventory for MySQL

This is a Dynamic Inventory for Ansible to be used together with MySQL.

It was written because we maintain a lot of servers and static inventory files did not meet our demand, and we like MySQL.

Usage

Simply call the script like the following

ansible-playbook -i mysql.py
# or
ansible -i mysql.py

Limitations also work

ansible-playbook -i mysql.py --limit foo.bar.com
ansible-playbook -i mysql.py --limit groupFoo

Setup

I won't explain the process of installing a database or creating the tables, see tables.sql for the required MySQL structure.

Once setup rename mysql.ini.dist to mysql.ini to suit your needs, if you don't want to use caching just put it on 0.

Groups

In the table group you create the groups you need and their variables,

Hosts

In the table host under host you place the IP/DNS for the system.

Facts

Under hostname you can fill in a value, this will be presented as a variable inventory_hostname during the play. You can modify the name of this Fact variable by changing the facts_hostname_var variable in my mysql.ini.

Relation between Hosts and Groups

The table hostgroups maps the relation between host and group using two FOREIGN KEYS.

Children

Groups can have other groups as children, use the table childgroups.

Note on Variables

This applies to host and group respectively. If no variables are needed either NULL it (actual MySQL NULL not the string) or use {}.

LICENSE

# Copyright (c) 2015 Productsup GmbH, Yorick Terweijden [email protected]
#
# As it is mostly based on the original Cobbler Dynamic Inventory
# https://github.com/ansible/ansible/blob/devel/contrib/inventory/cobbler.py
# the same license, the GPL-3 applies.

The GPL-3 can be found under the link.

ansible-dyninv-mysql's People

Contributors

0bp avatar dvershinin avatar tanji avatar terwey avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.