-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathstatus.sh
executable file
·38 lines (32 loc) · 1.03 KB
/
status.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# _ __ _______ _____ _ _
# | | \ \ / / __ \ / ____| | | |
# | | \ V /| | | | | | | | ___ _ _ __| |
# | | > < | | | | | | | |/ _ \| | | |/ _` |
# | |____ / . \| |__| | | |____| | (_) | |_| | (_| |
# |______/_/ \_\_____/ \_____|_|\___/ \__,_|\__,_|
#
# REQUIREMENTS
#
# apt install python-configparser
#
# Looking for a the host of a server? Pipe to grep
# ./status.sh | grep -B 10 example.com
#
# parse /etc/ansible/host file and get lxd_hosts
function lxd_hosts_get {
python - <<END
import configparser
config = configparser.ConfigParser(allow_no_value=True)
config.read('/etc/ansible/hosts')
for server in config['lxd_hosts']: print(server.split('.')[0])
END
}
# get list of servers
SERVERS=$(lxd_hosts_get)
# interate through list
for host in ${SERVERS}; do
echo "//////////////////////////////////////////////////////////////////////////"
echo $host
# lxd list server to get containers
lxc list $host:
done