rsync_mirror: add better logging #230
3 changed files with 12 additions and 4 deletions
|
@ -22,14 +22,17 @@
|
||||||
mode: "0400"
|
mode: "0400"
|
||||||
no_log: "{{ no_debug | default('true') }}"
|
no_log: "{{ no_debug | default('true') }}"
|
||||||
|
|
||||||
- name: Ensure rsync_mirror-Script is templated
|
- name: Ensure rsync_mirror-Scripts are templated
|
||||||
become: true
|
become: true
|
||||||
ansible.builtin.template:
|
ansible.builtin.template:
|
||||||
src: "rsync_mirror.sh.j2"
|
src: "{{ item }}.sh.j2"
|
||||||
dest: "/usr/bin/rsync_mirror.sh"
|
dest: "/usr/bin/{{ item }}.sh"
|
||||||
owner: "{{ rsync_mirror_user }}"
|
owner: "{{ rsync_mirror_user }}"
|
||||||
group: "{{ rsync_mirror_user_group }}"
|
group: "{{ rsync_mirror_user_group }}"
|
||||||
mode: "0750"
|
mode: "0750"
|
||||||
|
loop:
|
||||||
|
- rsync_mirror
|
||||||
|
- rsync_mirror_log
|
||||||
|
|
||||||
- name: Ensure services are present
|
- name: Ensure services are present
|
||||||
become: true
|
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 - $HOSTNAME" {{ my_mail }}
|
||||||
|
{# Anzahl der Elemente mal 5, da jeweils 5 Zeilen ausgegeben werden #}
|
|
@ -5,4 +5,4 @@ Description=Send a Mail for rsync_mirror service after error or success rsync_mi
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=oneshot
|
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
|
||||||
|
|
Loading…
Reference in a new issue