Add deploy-tws-motd
This commit is contained in:
57
deploy-tws-motd
Normal file
57
deploy-tws-motd
Normal 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
|
||||
Reference in New Issue
Block a user