diff --git a/roles/sdcron/tasks/main.yml b/roles/sdcron/tasks/main.yml index 2f6bf820..58715448 100644 --- a/roles/sdcron/tasks/main.yml +++ b/roles/sdcron/tasks/main.yml @@ -1,8 +1,8 @@ --- - name: Adding services to send status emails template: - src: etc/systemd/system/{{ item }}@.service.j2 - dst: /etc/systemd/system/{{ item }}@.service + src: "etc/systemd/system/{{ item }}@.service.j2" + dest: "/etc/systemd/system/{{ item }}@.service" owner: root group: root loop: @@ -11,26 +11,31 @@ - name: Deploy the status-sender template: - src: var/local/sendstatusmail.sh.j2 - dst: /var/local/sendstatusmail.sh + src: "var/local/sendstatusmail.sh.j2" + dest: "/var/local/sendstatusmail.sh" owner: root group: root mode: '0500' - name: Install sdcron timers template: - src: etc/systemd/system/sdcron.timer.j2 - dst: etc/systemd/system/{{ item.name }}.timer + src: "etc/systemd/system/sdcron.timer.j2" + dest: "/etc/systemd/system/{{ item.name }}.timer" loop: "{{ sdcron.tasks }}" - name: Install sdcron services template: - src: etc/systemd/system/sdcron.service.j2 - dst: etc/systemd/system/{{ item.name }}.service + src: "etc/systemd/system/sdcron.service.j2" + dest: "/etc/systemd/system/{{ item.name }}.service" loop: "{{ sdcron.tasks }}" +- name: Reload sd daemons + systemd: + daemon_reload: true + - name: Enable sdcron timers systemd: - name: {{ item.name }}.timer + name: "{{ item.name }}.timer" enabled: yes + state: "started" loop: "{{ sdcron.tasks }}" diff --git a/roles/sdcron/templates/etc/systemd/system/sdcron.service.j2 b/roles/sdcron/templates/etc/systemd/system/sdcron.service.j2 index e0644e0b..fdf2ef89 100644 --- a/roles/sdcron/templates/etc/systemd/system/sdcron.service.j2 +++ b/roles/sdcron/templates/etc/systemd/system/sdcron.service.j2 @@ -1,9 +1,10 @@ [Unit] Description=Service for {{ item.name }} -OnFailure=failuremail@%n.service -OnSuccess=successmail@%n.service +OnFailure=failuremail@%N.service +# TODO: comprendre pourquoi OnSuccess n'est pas reconnu par systemd (malgré systemd.unit(5)) [Service] Type=oneshot ExecStart={{ item.command }} +ExecStartPost=/usr/bin/systemctl start successmail@%N.service diff --git a/roles/sdcron/templates/var/local/sendstatusmail.sh.j2 b/roles/sdcron/templates/var/local/sendstatusmail.sh.j2 index fea44314..b1a68238 100644 --- a/roles/sdcron/templates/var/local/sendstatusmail.sh.j2 +++ b/roles/sdcron/templates/var/local/sendstatusmail.sh.j2 @@ -5,7 +5,7 @@ status="${1}" service_name="${2}" smtp_rcpt="nounous@crans.org" -/usr/bin/sendmail -t <