diff --git a/roles/mgrote_rsync/tasks/source.yml b/roles/mgrote_rsync/tasks/source.yml index d80183ff..2ca0a31c 100644 --- a/roles/mgrote_rsync/tasks/source.yml +++ b/roles/mgrote_rsync/tasks/source.yml @@ -22,14 +22,17 @@ mode: "0400" no_log: "{{ no_debug | default('true') }}" -- name: Ensure rsync_mirror-Script is templated +- name: Ensure rsync_mirror-Scripts are templated become: true ansible.builtin.template: - src: "rsync_mirror.sh.j2" - dest: "/usr/bin/rsync_mirror.sh" + src: "{{ item }}.sh.j2" + dest: "/usr/bin/{{ item }}.sh" owner: "{{ rsync_mirror_user }}" group: "{{ rsync_mirror_user_group }}" mode: "0750" + loop: + - rsync_mirror + - rsync_mirror_log - name: Ensure services are present become: true diff --git a/roles/mgrote_rsync/templates/rsync_mirror_log.sh.j2 b/roles/mgrote_rsync/templates/rsync_mirror_log.sh.j2 new file mode 100644 index 00000000..5b70bbaf --- /dev/null +++ b/roles/mgrote_rsync/templates/rsync_mirror_log.sh.j2 @@ -0,0 +1,5 @@ +#!/bin/bash +{{ file_header | default () }} + +/usr/bin/journalctl -u rsync_mirror.service -xe | grep -E '\-----------------------|Source:|Literal data:|matched data:|sent:' | tail -n {{ rsync_mirror_dirs | length * 5 }} | mail -aFROM:{{ rsync_mirror_user }}@mgrote.net -s "rsync_mirror - $HOSTNAME" {{ my_mail }} +{# Anzahl der Elemente mal 5, da jeweils 5 Zeilen ausgegeben werden #} diff --git a/roles/mgrote_rsync/templates/rsync_mirror_mail.service.j2 b/roles/mgrote_rsync/templates/rsync_mirror_mail.service.j2 index 072df75e..356fea73 100644 --- a/roles/mgrote_rsync/templates/rsync_mirror_mail.service.j2 +++ b/roles/mgrote_rsync/templates/rsync_mirror_mail.service.j2 @@ -5,4 +5,4 @@ Description=Send a Mail for rsync_mirror service after error or success rsync_mi [Service] Type=oneshot -ExecStart=/bin/bash -c '/usr/bin/journalctl -u rsync_mirror.service -n 30 | mail -aFROM:{{ rsync_mirror_user }}@mgrote.net -s "rsync_mirror - %H" {{ my_mail }}' +ExecStart=/usr/bin/rsync_mirror_log.sh