homeserver/roles/mgrote_rsync/tasks/source.yml

77 lines
1.8 KiB
YAML
Raw Normal View History

2024-10-28 18:17:23 +01:00
---
2024-10-28 18:24:29 +01:00
- name: Ensure needed dirs exist
2024-10-28 18:17:23 +01:00
become: true
2024-10-28 18:24:29 +01:00
ansible.builtin.file:
path: "{{ item }}"
state: directory
2024-10-28 18:27:43 +01:00
owner: "{{ rsync_mirror_user }}"
group: "{{ rsync_mirror_user_group }}"
2024-10-28 18:24:29 +01:00
mode: "0600"
with_items:
- "/etc/rsync_mirror/"
- "/etc/rsync_mirror/.ssh"
2024-10-28 18:32:18 +01:00
- name: Ensure SSH-Private-Key is templated
2024-10-28 18:24:29 +01:00
become: true
ansible.builtin.template:
2024-10-28 18:32:18 +01:00
src: private_key.j2
dest: "/etc/rsync_mirror/.ssh/id_rsync_mirror"
owner: "{{ rsync_mirror_user }}"
group: "{{ rsync_mirror_user_group }}"
mode: "0400"
2024-10-28 19:02:17 +01:00
# no_log: true # tido
2024-10-28 18:32:18 +01:00
2024-10-28 19:18:20 +01:00
- name: Ensure SSH-Config is templated
become: true
ansible.builtin.template:
src: ssh-config.j2
dest: "/home/rsync_mirror/.ssh/config"
owner: "{{ rsync_mirror_user }}"
group: "{{ rsync_mirror_user_group }}"
mode: "0400"
2024-10-28 18:32:18 +01:00
- name: Ensure rsync_mirror-Script is templated
become: true
ansible.builtin.template:
src: "rsync_mirror.sh.j2"
dest: "/usr/bin/rsync_mirror.sh"
2024-10-28 18:24:29 +01:00
owner: root
group: root
2024-10-28 18:32:18 +01:00
mode: "0750"
2024-10-28 18:24:29 +01:00
- 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:
2024-10-28 18:27:43 +01:00
- rsync_mirror.service
- rsync_mirror.timer
- rsync_mirror_mail.service
2024-10-28 18:24:29 +01:00
- name: Ensure timer unit is enabled
become: true
ansible.builtin.systemd:
2024-10-28 18:27:43 +01:00
name: rsync_mirror.timer
2024-10-28 18:24:29 +01:00
enabled: true
masked: false
state: started
notify:
- systemctl daemon-reload
- name: Ensure service units are enabled
become: true
ansible.builtin.systemd:
name: "{{ item }}"
2024-10-28 19:19:27 +01:00
masked: true # todo umkehren
enabled: false # todo umkehren
2024-10-28 18:24:29 +01:00
loop:
2024-10-28 18:27:43 +01:00
- rsync_mirror.service
- rsync_mirror.timer
- rsync_mirror_mail.service