homeserver/roles/mgrote_rsync/tasks/source.yml

72 lines
1.7 KiB
YAML
Raw Normal View History

---
- name: Ensure needed dirs exist
become: true
ansible.builtin.file:
path: "{{ item }}"
state: directory
owner: "{{ rsync_mirror_user }}"
group: "{{ rsync_mirror_user_group }}"
mode: "0700"
with_items:
- "/etc/rsync_mirror/"
- "/etc/rsync_mirror/.ssh"
- "/home/{{ rsync_mirror_user }}/.ssh"
- name: Ensure SSH-Private-Key is templated
become: true
ansible.builtin.template:
src: private_key.j2
dest: "/etc/rsync_mirror/.ssh/id_rsync_mirror"
owner: "{{ rsync_mirror_user }}"
group: "{{ rsync_mirror_user_group }}"
mode: "0400"
no_log: "{{ no_debug | default('true') }}"
- name: Ensure rsync_mirror-Scripts are templated
become: true
ansible.builtin.template:
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
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
- 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
- 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