Update deploy-tws-motd
This commit is contained in:
@@ -8,6 +8,17 @@
|
|||||||
tws_short: "TWS"
|
tws_short: "TWS"
|
||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
|
- name: Remove static MOTD file (Debian default)
|
||||||
|
file:
|
||||||
|
path: /etc/motd
|
||||||
|
state: absent
|
||||||
|
|
||||||
|
- name: Ensure dynamic MOTD symlink
|
||||||
|
file:
|
||||||
|
src: /run/motd.dynamic
|
||||||
|
dest: /etc/motd
|
||||||
|
state: link
|
||||||
|
|
||||||
- name: Check for default Ubuntu MOTD scripts
|
- name: Check for default Ubuntu MOTD scripts
|
||||||
stat:
|
stat:
|
||||||
path: "/etc/update-motd.d/{{ item }}"
|
path: "/etc/update-motd.d/{{ item }}"
|
||||||
@@ -29,35 +40,49 @@
|
|||||||
mode: "0755"
|
mode: "0755"
|
||||||
content: |
|
content: |
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
ORG="{{ tws_org }}"
|
ORG="{{ tws_org }}"
|
||||||
SHORT="{{ tws_short }}"
|
SHORT="{{ tws_short }}"
|
||||||
|
|
||||||
HOSTNAME="$(hostname)"
|
WIDTH=58
|
||||||
|
|
||||||
|
line() {
|
||||||
|
printf "║ %-*s ║\n" $((WIDTH-4)) "$1"
|
||||||
|
}
|
||||||
|
|
||||||
|
border_top() {
|
||||||
|
printf "╔%s╗\n" "$(printf '═%.0s' $(seq 1 $((WIDTH-2))))"
|
||||||
|
}
|
||||||
|
|
||||||
|
border_mid() {
|
||||||
|
printf "╠%s╣\n" "$(printf '═%.0s' $(seq 1 $((WIDTH-2))))"
|
||||||
|
}
|
||||||
|
|
||||||
|
border_bot() {
|
||||||
|
printf "╚%s╝\n" "$(printf '═%.0s' $(seq 1 $((WIDTH-2))))"
|
||||||
|
}
|
||||||
|
|
||||||
|
HOST="$(hostname)"
|
||||||
OS="$(lsb_release -ds 2>/dev/null || grep PRETTY_NAME /etc/os-release | cut -d= -f2 | tr -d '"')"
|
OS="$(lsb_release -ds 2>/dev/null || grep PRETTY_NAME /etc/os-release | cut -d= -f2 | tr -d '"')"
|
||||||
KERNEL="$(uname -r)"
|
KERNEL="$(uname -r)"
|
||||||
IP="$(hostname -I | awk '{print $1}')"
|
IP="$(hostname -I | awk '{print $1}')"
|
||||||
UPTIME="$(uptime -p | sed 's/up //')"
|
UPTIME="$(uptime -p | sed 's/up //')"
|
||||||
LOAD="$(awk '{print $1}' /proc/loadavg)"
|
LOAD="$(awk '{print $1}' /proc/loadavg)"
|
||||||
|
MEM="$(free -h | awk '/Mem:/ {print $3 " / " $2}')"
|
||||||
MEM_USED="$(free -h | awk '/Mem:/ {print $3}')"
|
DISK="$(df -h / | awk 'NR==2 {print $5 " used (/)"}')"
|
||||||
MEM_TOTAL="$(free -h | awk '/Mem:/ {print $2}')"
|
|
||||||
|
|
||||||
DISK_USED="$(df -h / | awk 'NR==2 {print $5}')"
|
|
||||||
USERS="$(who | wc -l)"
|
USERS="$(who | wc -l)"
|
||||||
|
|
||||||
cat <<EOF
|
border_top
|
||||||
╔══════════════════════════════════════════════════════════╗
|
line "${ORG} • ${SHORT} Infrastructure"
|
||||||
║ ${ORG} • ${SHORT} Infrastructure
|
border_mid
|
||||||
╠══════════════════════════════════════════════════════════╣
|
line "Host : ${HOST}"
|
||||||
║ Host : ${HOSTNAME}
|
line "OS : ${OS}"
|
||||||
║ OS : ${OS}
|
line "Kernel : ${KERNEL}"
|
||||||
║ Kernel : ${KERNEL}
|
line "IP : ${IP}"
|
||||||
║ IP : ${IP}
|
line "Uptime : ${UPTIME}"
|
||||||
║ Uptime : ${UPTIME}
|
border_mid
|
||||||
╠══════════════════════════════════════════════════════════╣
|
line "CPU Load : ${LOAD}"
|
||||||
║ CPU Load : ${LOAD}
|
line "Memory : ${MEM}"
|
||||||
║ Memory : ${MEM_USED} / ${MEM_TOTAL}
|
line "Disk : ${DISK}"
|
||||||
║ Disk : ${DISK_USED} used (/)
|
line "Users : ${USERS} logged in"
|
||||||
║ Users : ${USERS} logged in
|
border_bot
|
||||||
╚══════════════════════════════════════════════════════════╝
|
|
||||||
EOF
|
|
||||||
|
|||||||
Reference in New Issue
Block a user