Initial commit of PVC Ansible role
This commit is contained in:
18
roles/base/templates/usr/local/sbin/dpkg-cleanup.sh.j2
Executable file
18
roles/base/templates/usr/local/sbin/dpkg-cleanup.sh.j2
Executable file
@ -0,0 +1,18 @@
|
||||
#!/bin/bash
|
||||
|
||||
# dpkg-cleanup.sh - Remove obsolete packages and config files
|
||||
# {{ ansible_managed }}
|
||||
|
||||
# Phase 1 - purge `rc` packages
|
||||
PACKAGE_LIST=( $( dpkg --list | awk '/^rc/{ print $2 } /^ri/{ print $2 }' ) )
|
||||
apt purge -y ${PACKAGE_LIST[@]}
|
||||
|
||||
# Phase 2 - autoremove packages
|
||||
apt autoremove --purge -y
|
||||
|
||||
# Phase 3 - clean archives
|
||||
apt clean
|
||||
|
||||
# Phase 4 - find and remove obsolete config files
|
||||
OLD_FILES_LIST=( $( find /etc -type f -a \( -name '*.dpkg-*' -o -name '*.ucf-*' \) 2>/dev/null ) )
|
||||
rm -f ${OLD_FILES_LIST[@]}
|
23
roles/base/templates/usr/local/sbin/loghost-archive.sh.j2
Executable file
23
roles/base/templates/usr/local/sbin/loghost-archive.sh.j2
Executable file
@ -0,0 +1,23 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Archive old logs on loghost
|
||||
# {{ ansible_managed }}
|
||||
|
||||
LOGPATH=/srv/log
|
||||
ARCHIVEPATH=${LOGPATH}/archive/
|
||||
test -d $ARCHIVEPATH || mkdir -p $ARCHIVEPATH
|
||||
for LOGFILE in \
|
||||
kern.log \
|
||||
daemon.log \
|
||||
haproxy.log \
|
||||
auth.log \
|
||||
cron.log \
|
||||
mail.log \
|
||||
boot.log \
|
||||
system.log
|
||||
do
|
||||
test -d ${ARCHIVEPATH}/${LOGFILE} || mkdir -p ${ARCHIVEPATH}/${LOGFILE}
|
||||
mv ${LOGPATH}/${LOGFILE}-* ${ARCHIVEPATH}/${LOGFILE}
|
||||
gzip ${ARCHIVEPATH}/${LOGFILE}/*
|
||||
find ${ARCHIVEPATH}/${LOGFILE} -type f -ctime +90 -exec rm {} \;
|
||||
done
|
26
roles/base/templates/usr/local/sbin/update-motd.sh.j2
Executable file
26
roles/base/templates/usr/local/sbin/update-motd.sh.j2
Executable file
@ -0,0 +1,26 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Update dynamic MOTD file
|
||||
# {{ ansible_managed }}
|
||||
|
||||
set -o errexit
|
||||
|
||||
TMPFILE=$(mktemp)
|
||||
TGTFILE=/run/pvc-motd.dynamic
|
||||
DEBVER="({{ ansible_lsb.description }})"
|
||||
|
||||
echo >> $TMPFILE
|
||||
echo "\033[01;34mParallel Virtual Cluster \033[01;36m${DEBVER}\033[0m" >> $TMPFILE
|
||||
echo -n "> \033[01;32m$(hostname)\033[0m" >> $TMPFILE
|
||||
if test -f /etc/hostdesc; then
|
||||
echo " - $( cat /etc/hostdesc )" >> $TMPFILE
|
||||
else
|
||||
echo >> $TMPFILE
|
||||
fi
|
||||
# Get machine information
|
||||
echo "> \033[1;37mPVC node\033[0m on \033[1;31m$(
|
||||
/usr/sbin/dmidecode | grep -A1 'Chassis Information' | tail -1 | awk -F':' '{print $2}' | tr -s ' '
|
||||
)\033[0m hardware" >> $TMPFILE
|
||||
echo "> $(/bin/uname -srvmo)" >> $TMPFILE
|
||||
|
||||
mv $TMPFILE $TGTFILE || rm $TMPFILE
|
Reference in New Issue
Block a user