rsync_mirror: add better logging #230
3 changed files with 12 additions and 5 deletions
|
@ -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
|
||||
|
|
5
roles/mgrote_rsync/templates/rsync_mirror_log.sh.j2
Normal file
5
roles/mgrote_rsync/templates/rsync_mirror_log.sh.j2
Normal file
|
@ -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 - %H" {{ my_mail }}
|
||||
{# Anzahl der Elemente mal 5, da jeweils 5 Zeilen ausgegeben werden #}
|
|
@ -5,5 +5,4 @@ Description=Send a Mail for rsync_mirror service after error or success rsync_mi
|
|||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
{# Anzahl der Elemente mal 5, da jeweils 5 Zeilen ausgegeben werden #}
|
||||
ExecStart=/bin/bash -c '/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 - %H" {{ my_mail }}'
|
||||
ExecStart=/usr/bin/rsync_mirror_log.sh
|
||||
|
|
Loading…
Reference in a new issue