Add deploy-tws-motd

This commit is contained in:
2026-01-19 20:40:25 -05:00
parent 629080bf4d
commit 7d75e46bf1

57
deploy-tws-motd Normal file
View File

@@ -0,0 +1,57 @@
---
- name: Deploy TWS MOTD
hosts: all
become: true
vars:
tws_org: "TheWrightServer"
tws_short: "TWS"
tasks:
- name: Disable default Ubuntu MOTD noise
file:
path: "/etc/update-motd.d/{{ item }}"
mode: "0644"
loop:
- 10-help-text
- 50-motd-news
ignore_errors: true
- name: Deploy TWS MOTD script
copy:
dest: /etc/update-motd.d/10-tws
mode: "0755"
content: |
#!/bin/bash
ORG="{{ tws_org }}"
SHORT="{{ tws_short }}"
HOSTNAME="$(hostname)"
OS="$(lsb_release -ds 2>/dev/null || grep PRETTY_NAME /etc/os-release | cut -d= -f2 | tr -d '"')"
KERNEL="$(uname -r)"
IP="$(hostname -I | awk '{print $1}')"
UPTIME="$(uptime -p | sed 's/up //')"
LOAD="$(awk '{print $1}' /proc/loadavg)"
MEM_USED="$(free -h | awk '/Mem:/ {print $3}')"
MEM_TOTAL="$(free -h | awk '/Mem:/ {print $2}')"
DISK_USED="$(df -h / | awk 'NR==2 {print $5}')"
USERS="$(who | wc -l)"
cat <<EOF
╔══════════════════════════════════════════════════════════╗
║ ${ORG} • ${SHORT} Infrastructure
╠══════════════════════════════════════════════════════════╣
║ Host : ${HOSTNAME}
║ OS : ${OS}
║ Kernel : ${KERNEL}
║ IP : ${IP}
║ Uptime : ${UPTIME}
╠══════════════════════════════════════════════════════════╣
║ CPU Load : ${LOAD}
║ Memory : ${MEM_USED} / ${MEM_TOTAL}
║ Disk : ${DISK_USED} used (/)
║ Users : ${USERS} logged in
╚══════════════════════════════════════════════════════════╝
EOF