From 77650ce45fbf59b5ae63edc7e5fa91d9ba006754 Mon Sep 17 00:00:00 2001 From: Michael Grote Date: Sun, 10 Nov 2024 10:26:53 +0100 Subject: [PATCH 1/5] fgds --- roles/mgrote_rsync/templates/rsync_mirror_mail.service.j2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/mgrote_rsync/templates/rsync_mirror_mail.service.j2 b/roles/mgrote_rsync/templates/rsync_mirror_mail.service.j2 index 072df75e..22d63698 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=/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 * 6 }} | mail -aFROM:{{ rsync_mirror_user }}@mgrote.net -s "rsync_mirror - %H" {{ my_mail }}' -- 2.43.0 From 856390bd676c0b950b581e739b83f218c3e1993a Mon Sep 17 00:00:00 2001 From: Michael Grote Date: Sun, 10 Nov 2024 10:32:22 +0100 Subject: [PATCH 2/5] docs --- roles/mgrote_rsync/templates/rsync_mirror_mail.service.j2 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/roles/mgrote_rsync/templates/rsync_mirror_mail.service.j2 b/roles/mgrote_rsync/templates/rsync_mirror_mail.service.j2 index 22d63698..646bafba 100644 --- a/roles/mgrote_rsync/templates/rsync_mirror_mail.service.j2 +++ b/roles/mgrote_rsync/templates/rsync_mirror_mail.service.j2 @@ -5,4 +5,5 @@ 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 -xe | grep -E '\-----------------------|Source:|Literal data:|matched data:|sent' | tail -n {{ rsync_mirror_dirs | length * 6 }} | mail -aFROM:{{ rsync_mirror_user }}@mgrote.net -s "rsync_mirror - %H" {{ my_mail }}' +{# 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 }}' -- 2.43.0 From aab17f9df48202e0558608009ea86dfb9c41a579 Mon Sep 17 00:00:00 2001 From: Michael Grote Date: Mon, 11 Nov 2024 13:19:18 +0100 Subject: [PATCH 3/5] dfg --- roles/mgrote_rsync/tasks/source.yml | 9 ++++++--- roles/mgrote_rsync/templates/rsync_mirror_log.sh.j2 | 5 +++++ .../mgrote_rsync/templates/rsync_mirror_mail.service.j2 | 3 +-- 3 files changed, 12 insertions(+), 5 deletions(-) create mode 100644 roles/mgrote_rsync/templates/rsync_mirror_log.sh.j2 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..93e039cf --- /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 - %H" {{ 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 646bafba..356fea73 100644 --- a/roles/mgrote_rsync/templates/rsync_mirror_mail.service.j2 +++ b/roles/mgrote_rsync/templates/rsync_mirror_mail.service.j2 @@ -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 -- 2.43.0 From 333743637616181451d663357f90357e6291e257 Mon Sep 17 00:00:00 2001 From: Michael Grote Date: Mon, 11 Nov 2024 13:25:39 +0100 Subject: [PATCH 4/5] asdf --- roles/mgrote_rsync/templates/rsync_mirror_log.sh.j2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/mgrote_rsync/templates/rsync_mirror_log.sh.j2 b/roles/mgrote_rsync/templates/rsync_mirror_log.sh.j2 index 93e039cf..4f2fdeb6 100644 --- a/roles/mgrote_rsync/templates/rsync_mirror_log.sh.j2 +++ b/roles/mgrote_rsync/templates/rsync_mirror_log.sh.j2 @@ -1,5 +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 }} +/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 #} -- 2.43.0 From 4ea43bafd6e5f1e02a58f794f5aeafa00e8cfd6d Mon Sep 17 00:00:00 2001 From: Michael Grote Date: Mon, 11 Nov 2024 13:35:03 +0100 Subject: [PATCH 5/5] sf --- roles/mgrote_rsync/templates/rsync_mirror_log.sh.j2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/mgrote_rsync/templates/rsync_mirror_log.sh.j2 b/roles/mgrote_rsync/templates/rsync_mirror_log.sh.j2 index 4f2fdeb6..5b70bbaf 100644 --- a/roles/mgrote_rsync/templates/rsync_mirror_log.sh.j2 +++ b/roles/mgrote_rsync/templates/rsync_mirror_log.sh.j2 @@ -1,5 +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 }} +/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 #} -- 2.43.0