homeserver/roles/mgrote_rsync/tasks/source.yml
2024-10-28 18:27:43 +01:00

69 lines
1.4 KiB
YAML

---
- name: Ensure packages are present
become: true
ansible.builtin.package:
name:
- rsync
state: present
- name: Ensure needed dirs exist
become: true
ansible.builtin.file:
path: "{{ item }}"
state: directory
owner: "{{ rsync_mirror_user }}"
group: "{{ rsync_mirror_user_group }}"
mode: "0600"
with_items:
- "/etc/rsync_mirror/"
- "/etc/rsync_mirror/.ssh"
- name: template syncoid.sh
become: true
ansible.builtin.template:
src: "syncoid.sh.j2"
dest: /usr/bin/syncoid.sh
owner: root
group: root
mode: "0755"
when:
- rsync_mirror_syncoid_destination_host
- name: Ensure services are present
become: true
ansible.builtin.template:
src: "{{ item }}.j2"
dest: "/etc/systemd/system/{{ item }}"
owner: root
group: root
mode: "0644"
notify:
- systemctl daemon-reload
loop:
- rsync_mirror.service
- rsync_mirror.timer
- rsync_mirror_mail.service
when: ytdl_active
- name: Ensure timer unit is enabled
become: true
ansible.builtin.systemd:
name: rsync_mirror.timer
enabled: true
masked: false
state: started
notify:
- systemctl daemon-reload
when: ytdl_active
- name: Ensure service units are enabled
become: true
ansible.builtin.systemd:
name: "{{ item }}"
masked: false
enabled: true
loop:
- rsync_mirror.service
- rsync_mirror.timer
- rsync_mirror_mail.service
when: ytdl_active