homeserver/roles/_mgrote.musterrolle_systemd/tasks/main.yml
mg 0e80178e9e Rolle: sanoid: systemd-override.d statt direkte Änderungen (#374)
Co-authored-by: Michael Grote <michael.grote@posteo.de>
Reviewed-on: mg/ansible#374
Co-authored-by: mg <michael.grote@posteo.de>
Co-committed-by: mg <michael.grote@posteo.de>
2022-05-27 12:30:43 +02:00

67 lines
1.8 KiB
YAML

---
- name: template systemd services
become: yes
ansible.builtin.template:
src: "rclone.service.j2"
dest: "/etc/systemd/system/name.service"
owner: root
group: root
mode: 0644
notify:
- systemctl daemon-reload
# wenn die unit über einen timer aktiviert wird muss sie nicht selber enabled werden, nur der timer muss enabled werden
- name: template rclone timer
become: yes
ansible.builtin.template:
src: "rclone.timer.j2"
dest: "/etc/systemd/system/rclone_{{ item.name }}.timer"
owner: root
group: root
mode: 0644
notify:
- systemctl daemon-reload
with_items:
- "{{ rclone_jobs }}"
# erstelle systemd-template
- name: template rclone_mail@.service.j2
become: yes
ansible.builtin.template:
src: "rclone_mail@.service.j2"
dest: "/etc/systemd/system/rclone_mail@.service"
owner: root
group: root
mode: 0644
notify:
- systemctl daemon-reload
# enable units, muss hier erfolgen statt als handler da sonst schonmit den units weiter gearbeitet wird obwohl sie noch nciht aktiv sind
- name: systemctl enable timer units
become: yes
ansible.builtin.systemd:
name: "rclone_{{ item.name }}.timer"
enabled: yes
masked: no
state: started
with_items:
- "{{ rclone_jobs }}"
notify:
- systemctl daemon-reload
# ändere vorhandene unit; override.d statt direkte änderungen
- name: set timer
become: true
ansible.builtin.blockinfile:
create: yes
mode: 0644
owner: root
group: root
path: /lib/systemd/system/sanoid.timer.d/override.conf
block: |
[Timer]
OnCalendar = {{ sanoid_timer }}
when: sanoid_timer is defined
notify:
- systemctl daemon-reload