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

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.

主站蜘蛛池模板: 竹北市| 湖南省| 明溪县| 望江县| 新安县| 贵德县| 丹寨县| 阳高县| 横峰县| 自治县| 丰宁| 兴国县| 大同县| 武城县| 湘潭市| 甘洛县| 海林市| 太湖县| 张北县| 苍山县| 广汉市| 札达县| 盘山县| 镇远县| 望谟县| 定州市| 新民市| 东至县| 怀远县| 高淳县| 昌邑市| 天气| 健康| 绥化市| 独山县| 济南市| 靖宇县| 巴林右旗| 文水县| 连南| 农安县|