Pigsty CMDB
Use PostgreSQL as Pigsty config inventory instead of static yaml config file
Instead of a static config file, you can use postgres as an inventory for Pigsty.
Using CMDB as a dynamic Inventory for Ansible has several advantages: metadata is presented as data tables in a highly structured way, and database constraints ensure consistency. The CMDB also allows you to use third-party tools to manage Pigsty metadata.
Currently, Pigsty’s CMDB only supports PostgreSQL clusters. If your pigsty.yml contains Redis and MatrixDB, it will report an error. It is recommended to use a separate pigsty.yml config file to manage Redis and Greenplum clusters.
The Pigsty CMDBmode is automatically created during the initialization of the pg-meta meta DB (files/cmdb.sql) and is located in the meta database’s pigsty mode of the meta DB. Static config files can be loaded into the CMDB using bin/inventory_load.
You must execute infra.yml entirely in the meta node after installation before you can use CMDB.
1. usage: inventory_load [-h] [-p PATH] [-d CMDB_URL]
3. load config arguments
5. optional arguments:
6. -h, --help show this help message and exit
7. -p PATH, --path PATH config path, ${PIGSTY_HOME}/pigsty.yml by default
8. -d DATA, --data DATA postgres cmdb pgurl, ${METADB_URL} by default
By default, executing the script without parameters will load $PIGSTY_HOME/pigsty.yml into the CMDB under the name pgsql.
1. bin/inventory_load # load default config to default cmdb
2. bin/inventory_load -p files/conf/pigsty-demo.yml
3. bin/inventory_load -p files/conf/pigsty-dcs3.yml -d postgresql://dbuser_meta:DBUser.Meta@10.10.10.10:5432/meta
CMDB as Inventory
Once the original config file is loaded into the CMDB as the initial data, Ansible can be configured to use the CMDB as the inventory.
1. bin/inventory_cmdb
You can switch back to a static config file.
1. bin/inventory_conf
Modifying the inventory is essentially a matter of editing ansible. cfg in the Pigsty dir.
1. ---
2. inventory = pigsty.yml
3. +++
4. inventory = inventory.sh
Last modified 2022-06-04: fill en docs (5a858d3)
