官术网_书友最值得收藏!

Using dynamic inventory

We have talked about dynamic inventory a little bit in this chapter. Throughout this book, in every chapter, we are going to talk about and use dynamic inventory. So let us explore the concept in a bit more depth.

Reiterating what we wrote earlier, dynamic inventory is useful for infrastructures that are dynamic in nature or for cases where we do not want to or cannot maintain a static inventory. Dynamic inventory queries a datasource and builds the inventory in real time. For the sake of this book, we will query cloud providers to get data and build the inventory. Ansible provides dynamic inventory scripts for most of the popular cloud providers.

However, it is simple to create a dynamic inventory script by ourselves. Any executable script that can return a JSON with a list of inventory host groups and hosts in a predetermined format, when passed with a parameter --list can be used as an inventory script. A very simple inventory would output something like this:

{
"application": ["10.0.0.11", "10.0.0.12"],
"database": ["10.0.1.11"]
}

More elaborate inventory scripts would output much more information like instance tags, names, operating systems, geographical locations, and, also known as host facts.

主站蜘蛛池模板: 兰溪市| 丹江口市| 牡丹江市| 罗山县| 达尔| 宽城| 昭平县| 五指山市| 庄河市| 灌云县| 滦南县| 札达县| 民乐县| 南澳县| 滁州市| 花垣县| 濮阳市| 千阳县| 景谷| 湄潭县| 丰都县| 论坛| 景德镇市| 漳州市| 宝丰县| 朔州市| 青龙| 祁东县| 固镇县| 武川县| 金阳县| 防城港市| 桃源县| 元氏县| 探索| 乳山市| 衡东县| 霍林郭勒市| 龙口市| 长宁区| 周口市|