--- - name: Temporarily store the password of the SMTP user template: src: tmppass.j2 dst: /tmp/sdcron_pass owner: root group: root - name: Launch systemd-creds encrypt on the password for sdcron, and store the result in a variable command: systemd-creds --pretty --name=smtppass encrypt /tmp/sdcron_pass - register: creds - name: Delete the password of the SMTP user file: state: absent path: /tmp/sdcron_pass - name: Adding services to send status emails template: src: etc/systemd/system/{{ item }}@.service.j2 dst: /etc/systemd/system/{{ item }}@.service owner: root group: root loop: - successmail - failuremail - name: Deploy the status-sender template: src: var/local/sendstatusmail.sh.j2 dst: /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 loop: "{{ sdcron.tasks }}" - name: Install sdcron services template: src: etc/systemd/system/sdcron.service.j2 dst: etc/systemd/system/{{ item.name }}.service loop: "{{ sdcron.tasks }}" - name: Enable sdcron timers systemd: name: {{ item.name }}.timer enabled: yes loop: "{{ sdcron.tasks }}"