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

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.

主站蜘蛛池模板: 登封市| 宝山区| 县级市| 沂源县| 竹山县| 平顶山市| 莱阳市| 平谷区| 石泉县| 吴堡县| 秦安县| 万源市| 武汉市| 岢岚县| 翼城县| 封开县| 光山县| 磐石市| 天全县| 山西省| 习水县| 阳信县| 彝良县| 龙海市| 通江县| 萝北县| 成都市| 根河市| 靖安县| 江门市| 洛隆县| 石楼县| 肇源县| 呼和浩特市| 民权县| 嵩明县| 马尔康县| 黄龙县| 富民县| 海丰县| 沙田区|