more stuff
This commit is contained in:
parent
6a43132bc8
commit
79e6a1a543
18 changed files with 426 additions and 144 deletions
|
|
@ -87,7 +87,7 @@ check_prerequisites() {
|
|||
fi
|
||||
|
||||
# Check if vipy is configured
|
||||
if ! grep -q "^\[vipy\]" "$ANSIBLE_DIR/inventory.ini"; then
|
||||
if [ -z "$(get_hosts_from_inventory "vipy")" ]; then
|
||||
print_error "vipy not configured in inventory.ini"
|
||||
print_info "Layer 7 requires vipy VPS"
|
||||
((errors++))
|
||||
|
|
@ -104,10 +104,40 @@ check_prerequisites() {
|
|||
}
|
||||
|
||||
get_hosts_from_inventory() {
|
||||
local group="$1"
|
||||
local target="$1"
|
||||
cd "$ANSIBLE_DIR"
|
||||
ansible-inventory -i inventory.ini --list | \
|
||||
python3 -c "import sys, json; data=json.load(sys.stdin); print(' '.join(data.get('$group', {}).get('hosts', [])))" 2>/dev/null || echo ""
|
||||
python3 - "$target" <<'PY' 2>/dev/null || echo ""
|
||||
import json, sys
|
||||
data = json.load(sys.stdin)
|
||||
target = sys.argv[1]
|
||||
if target in data:
|
||||
print(' '.join(data[target].get('hosts', [])))
|
||||
else:
|
||||
hostvars = data.get('_meta', {}).get('hostvars', {})
|
||||
if target in hostvars:
|
||||
print(target)
|
||||
PY
|
||||
}
|
||||
|
||||
get_host_ip() {
|
||||
local target="$1"
|
||||
cd "$ANSIBLE_DIR"
|
||||
ansible-inventory -i inventory.ini --list | \
|
||||
python3 - "$target" <<'PY' 2>/dev/null || echo ""
|
||||
import json, sys
|
||||
data = json.load(sys.stdin)
|
||||
target = sys.argv[1]
|
||||
hostvars = data.get('_meta', {}).get('hostvars', {})
|
||||
if target in hostvars:
|
||||
print(hostvars[target].get('ansible_host', target))
|
||||
else:
|
||||
hosts = data.get(target, {}).get('hosts', [])
|
||||
if hosts:
|
||||
first = hosts[0]
|
||||
hv = hostvars.get(first, {})
|
||||
print(hv.get('ansible_host', first))
|
||||
PY
|
||||
}
|
||||
|
||||
check_dns_configuration() {
|
||||
|
|
@ -116,7 +146,7 @@ check_dns_configuration() {
|
|||
cd "$ANSIBLE_DIR"
|
||||
|
||||
# Get vipy IP
|
||||
local vipy_ip=$(ansible-inventory -i inventory.ini --list | python3 -c "import sys, json; data=json.load(sys.stdin); hosts=data.get('vipy', {}).get('hosts', []); print(hosts[0] if hosts else '')" 2>/dev/null)
|
||||
local vipy_ip=$(get_host_ip "vipy")
|
||||
|
||||
if [ -z "$vipy_ip" ]; then
|
||||
print_error "Could not determine vipy IP from inventory"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue