Add basic motd to all machines

This commit is contained in:
Salt 2020-09-16 13:36:11 -05:00
parent 2a43b55cdd
commit acc12fbaa0
2 changed files with 42 additions and 0 deletions

View File

@ -33,6 +33,7 @@
copy: copy:
src: "motd-news" src: "motd-news"
dest: "/etc/default/motd-news" dest: "/etc/default/motd-news"
tags: [ motd ]
- name: Disable default update-motd tasks - name: Disable default update-motd tasks
file: file:
path: "/etc/update-motd.d/{{ item }}" path: "/etc/update-motd.d/{{ item }}"
@ -49,7 +50,14 @@
- "92-unattended-upgrades" - "92-unattended-upgrades"
- "95-hwe-eol" - "95-hwe-eol"
- "97-overlayroot" - "97-overlayroot"
tags: [ motd ]
when: ansible_distribution == "Ubuntu" when: ansible_distribution == "Ubuntu"
- name: Add update-motd tasks
template:
src: 50-ansible-motd.sh
dest: /etc/update-motd.d/50-ansible
mode: "0755"
tags: [ motd ]
- name: Configure Ansible user - name: Configure Ansible user
include_tasks: ansibleuser.yml include_tasks: ansibleuser.yml
become: yes become: yes

View File

@ -0,0 +1,34 @@
#! /bin/sh
#
# 50-ansible-motd.sh
# Copyright (C) 2020 Vintage Salt <rehashedsalt@cock.li>
#
# Distributed under terms of the MIT license.
#
# Service statuses
if command -v systemctl > /dev/null 2>&1; then
len=20
printf "Services:\n"
for unit in \
9iron-backup \
ansible-pull
do
systemctl status $unit > /dev/null 2>&1
case $? in
0)
printf " * %-${len}.${len}s\e[32mRunning\e[0m\n" $unit
;;
1|2)
printf " * %-${len}.${len}s\e[31mDead\e[0m\n" $unit
;;
3)
printf " * %-${len}.${len}s\e[34mExited\e[0m\n" $unit
;;
*)
printf " * %-${len}.${len}s\e[33mUnknown\e[0m\n" "$unit"
;;
esac
done
fi