Files
zabbix-ansible/ansible/update-inventory.sh
2022-11-08 17:02:57 +07:00

17 lines
403 B
Bash
Executable File

#!/bin/bash
echo "[cluster-nodes]" > ./ansible/inventory
echo "[cluster-nodes]" > ./ansible/inventory-zabbix
k=1
node_name=node
while read line; do
ip="$(grep -oE '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' <<< "$line")"
[[ $ip ]] && {
echo "$ip" >> ./ansible/inventory
echo "$ip zabbix_agent_hostname=${node_name}$k" >> ./ansible/inventory-zabbix
((k++))
}
done < cluster.yml