Update porygon-management.sh
This commit is contained in:
+27
-2
@@ -5,12 +5,15 @@ ROOT=(-e 'ansible_become=false')
|
|||||||
HOSTS_FILE="/root/templates/root.ini"
|
HOSTS_FILE="/root/templates/root.ini"
|
||||||
PASSWORD=(-k)
|
PASSWORD=(-k)
|
||||||
PLAYBOOK=/root/playbooks/master.yml
|
PLAYBOOK=/root/playbooks/master.yml
|
||||||
|
COLLECTOR_PLAYBOOK=/root/playbooks/update_collector.yml
|
||||||
PORT=22
|
PORT=22
|
||||||
ANSIBLE_PORT=()
|
ANSIBLE_PORT=()
|
||||||
SERVERS_JSON="/root/servers.json"
|
SERVERS_JSON="/root/servers.json"
|
||||||
LXC_JSON="/root/porygon_lxc_servers.json"
|
LXC_JSON="/root/porygon_lxc_servers.json"
|
||||||
|
PORYGON_KEY=/path/2/key
|
||||||
PORYGON_LXC_IP="1.2.3.4"
|
PORYGON_LXC_IP="1.2.3.4"
|
||||||
PORYGON_LXC_KEY="/path/2/key"
|
PORYGON_LXC_KEY="/path/2/key"
|
||||||
|
ALL_SERVERS_INI="/root/all_servers.ini"
|
||||||
|
|
||||||
|
|
||||||
###########FUNCTIONS#############
|
###########FUNCTIONS#############
|
||||||
@@ -49,6 +52,8 @@ web_handling
|
|||||||
echo "running scraper.py"
|
echo "running scraper.py"
|
||||||
/root/scraper.py
|
/root/scraper.py
|
||||||
|
|
||||||
|
sed -i "/^\[servers:vars\]/i ${IP} ansible_port=${PORT}" "$ALL_SERVERS_INI"
|
||||||
|
|
||||||
echo -e "\nall done, all successful\n\\(^0^)/"
|
echo -e "\nall done, all successful\n\\(^0^)/"
|
||||||
TO_ADD=$(sed 's/\$HOSTNAME/'"$HOSTNAME"'/g' /root/templates/main-page-paste.html)
|
TO_ADD=$(sed 's/\$HOSTNAME/'"$HOSTNAME"'/g' /root/templates/main-page-paste.html)
|
||||||
echo -e "place the following into /var/www/porygon/index.html\n\n$TO_ADD"
|
echo -e "place the following into /var/www/porygon/index.html\n\n$TO_ADD"
|
||||||
@@ -167,6 +172,20 @@ exit 0
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
update_collector() {
|
||||||
|
|
||||||
|
ansible-playbook -i "$ALL_SERVERS_INI" "$COLLECTOR_PLAYBOOK" --private-key "$PORYGON_KEY" "${APPEND[@]}" || {
|
||||||
|
echo "failed to run ansible playbook"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
echo -e "\npushed out new collector.py successfully to all servers\n
|
||||||
|
\\(^0^)/"
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
######RUNNING INTRO###########
|
######RUNNING INTRO###########
|
||||||
|
|
||||||
intro
|
intro
|
||||||
@@ -183,6 +202,11 @@ while getopts "udkph" flag; do
|
|||||||
SUDO=(--become --ask-become-pass)
|
SUDO=(--become --ask-become-pass)
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
c)
|
||||||
|
echo "pushing out the modified collector.py to all servers"
|
||||||
|
update_collector
|
||||||
|
;;
|
||||||
|
|
||||||
d)
|
d)
|
||||||
echo -e "ansible debug mode chosen\n"
|
echo -e "ansible debug mode chosen\n"
|
||||||
APPEND=(-vvv)
|
APPEND=(-vvv)
|
||||||
@@ -203,7 +227,8 @@ while getopts "udkph" flag; do
|
|||||||
;;
|
;;
|
||||||
|
|
||||||
h)
|
h)
|
||||||
echo -e "Options:\n-d - DEBUG - runs ansible with verbose (-vvv) flags\n\
|
echo -e "Options:\n-c - COPY - push out the latest collector.py to all servers\n\
|
||||||
|
-d - DEBUG - runs ansible with verbose (-vvv) flags\n\
|
||||||
-h - HELP - displays this help page\n-k - KEY - specifies connecting over ssh with a private key\n\
|
-h - HELP - displays this help page\n-k - KEY - specifies connecting over ssh with a private key\n\
|
||||||
-p - PORT - specifies which port to connect over ssh with\n\
|
-p - PORT - specifies which port to connect over ssh with\n\
|
||||||
-r - REMOVE - specifies which server to remove from porygon monitoring\n\
|
-r - REMOVE - specifies which server to remove from porygon monitoring\n\
|
||||||
@@ -220,4 +245,4 @@ while getopts "udkph" flag; do
|
|||||||
done
|
done
|
||||||
|
|
||||||
########RUNNING MAIN##########
|
########RUNNING MAIN##########
|
||||||
main
|
main
|
||||||
Reference in New Issue
Block a user