observability.svc.plus/bin/inventory_conf
2026-02-01 20:53:55 +08:00

32 lines
1.2 KiB
Bash
Executable File

#!/bin/bash
#==============================================================#
# File : inventory_conf
# Desc : use static config as inventory
# Ctime : 2021-07-22
# Mtime : 2021-07-22
# Path : bin/inventory_conf
# Deps : psql, sed
# License : Apache-2.0 @ https://pigsty.io/docs/about/license/
# Copyright : 2018-2026 Ruohang Feng / Vonng (rh@vonng.com)
#==============================================================#
#--------------------------------------------------------------#
# environment
#--------------------------------------------------------------#
APP_DIR="$(cd $(dirname $0) && pwd)"
PIGSTY_HOME=${PIGSTY_HOME-"${HOME}/pigsty"}
METADB_URL=${METADB_URL-"service=meta"}
PIGSTY_INVENTORY=${PIGSTY_HOME}/inventory.sh
ANSIBLE_CONFIG=${PIGSTY_HOME}/ansible.cfg
#--------------------------------------------------------------#
# Update ansible.cfg with inventory = pigsty.yml
#--------------------------------------------------------------#
echo "update ansible.cfg set inventory = pigsty.yml"
SED_CMD="s/inventory.*/inventory = pigsty.yml/g"
sed -ie "${SED_CMD}" ${ANSIBLE_CONFIG}
rm -rf "${ANSIBLE_CONFIG}e"
cat ${ANSIBLE_CONFIG} | grep inventory