Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# Travis configuration

dist: 'trusty'
dist: 'xenial'
sudo: 'required'

services:
Expand Down
2 changes: 1 addition & 1 deletion meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ galaxy_info:
- 'system'
dependencies:
- src: 'Temelio.ssmtp'
version: '0.1.0'
version: '0.1.1'
when: 'ssmtp_use_ansible_galaxy_dependencies or _use_role_dependencies'
2 changes: 1 addition & 1 deletion molecule/default/requirements.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
---

- src: 'Temelio.ssmtp'
version: '0.1.0'
version: '0.1.1'
8 changes: 4 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
docker==4.0.1
molecule==2.20.1
docker==4.0.2
molecule==2.20.2
pytest==4.5.0
six==1.11.0
tox==3.12.1
testinfra==1.19.0
tox==3.13.2
testinfra==3.0.5
6 changes: 6 additions & 0 deletions tasks/install.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---

- name: 'INSTALL | install procmail'
apt:
name: 'procmail'
state: 'present'
6 changes: 6 additions & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@
- 'role::systemd-notify'
- 'role::systemd-notify::init'

- name: 'INSTALL | Install package with lockfile'
become: True
include_tasks: "{{ role_path }}/tasks/install.yml"
tags:
- 'role::systemd-notify'
- 'role::systemd-notify::install'

- name: 'CONFIG | Manage config tasks'
become: 'True'
Expand Down
31 changes: 20 additions & 11 deletions templates/systemd.email.j2
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
#!/bin/bash
file=$(mktemp)
ERRORMAIL=$(mktemp)
LOCKFILE="/var/lock/$2"
FROMAIL="{{ notify_fromEmail }}"
SUBJECT=$(hostname -f)
set -eux

echo "TO: $1" >> $file
echo "From: admin@temelio.com" >> $file
echo "Subject: $HOSTNAME - $2" >> $file
echo "Content-Transfer-Encoding: 8bit" >> $file
echo "Content-Type: text/plain; charset=UTF-8" >> $file
echo "$(systemctl status --full "$2")" >> $file
echo "------------------------- logs tail -n 100 ------------------------" >> $file
echo "$(journalctl -n 100 -u "$2")" >> $file
cat $file |/usr/sbin/sendmail -t;
rm $file;
if lockfile -r0 -l900 $LOCKFFILE; then
echo "TO: $1" >> $ERRORMAIL
echo "From: $FROMAIL" >> $ERRORMAIL
echo "Subject: $SUBJECT - $2" >> $ERRORMAIL
echo "Content-Transfer-Encoding: 8bit" >> $ERRORMAIL
echo "Content-Type: text/plain; charset=UTF-8" >> $ERRORMAIL
echo "$(systemctl status --full "$2")" >> $ERRORMAIL
echo "------------------------- logs tail -n 100 ------------------------" >> $ERRORMAIL
echo "$(journalctl -n 100 -u "$2")" >> $ERRORMAIL
cat $ERRORMAIL |/usr/sbin/sendmail -t;
rm $ERRORMAIL;
else
echo 1>&2 "Fatal error: another process has been keeping the lock for too long or the lock file is inaccessible"
exit 3
fi
Loading