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

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.

主站蜘蛛池模板: 石河子市| 霍山县| 大竹县| 龙口市| 安岳县| 皋兰县| 惠东县| 肃宁县| 福清市| 南乐县| 吴川市| 云安县| 仪陇县| 太白县| 固始县| 邳州市| 任丘市| 荔浦县| 霞浦县| 海伦市| 哈密市| 鄂托克前旗| 孟津县| 建昌县| 朔州市| 云霄县| 河北区| 上饶市| 增城市| 黄大仙区| 连城县| 信阳市| 平南县| 渝北区| 通道| 永康市| 昌吉市| 布尔津县| 西藏| 油尖旺区| 遵化市|