homeserver/roles/mgrote.rclone/tasks/main.yml

102 lines
2.5 KiB
YAML
Raw Normal View History

---
- name: install packages
become: true
ansible.builtin.apt:
name:
- rclone
state: present
- name: Create rclone Directory
become: true
ansible.builtin.file:
path: "/etc/rclone"
state: directory
owner: root
group: root
recurse: true
- name: template rclone Configuration
become: true
ansible.builtin.blockinfile:
path: "/etc/rclone/rclone.conf"
block: "{{ rclone_config }}"
create: yes
owner: root
group: root
when: rclone_config is defined
no_log: true
- name: template rclone services
become: yes
ansible.builtin.template:
src: "rclone.service.j2"
dest: "/etc/systemd/system/rclone_{{ item.name }}.service"
owner: root
group: root
mode: 0644
notify:
- systemctl daemon-reload
with_items:
- "{{ rclone_jobs }}"
when: rclone_jobs is defined and item.state is true
- 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 }}"
when: rclone_jobs is defined and item.state is true
- name: remove old rclone services
become: yes
ansible.builtin.file:
path: "/etc/systemd/system/rclone_{{ item.name }}.service"
state: absent
notify:
- systemctl daemon-reload
with_items:
- "{{ rclone_jobs }}"
when: rclone_jobs is defined and item.state is false
- name: remove old rclone timers
become: yes
ansible.builtin.file:
path: "/etc/systemd/system/rclone_{{ item.name }}.timer"
state: absent
notify:
- systemctl daemon-reload
with_items:
- "{{ rclone_jobs }}"
when: rclone_jobs is defined and item.state is false
- 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
- 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 }}"
when: rclone_jobs is defined and item.state is true
notify:
- systemctl daemon-reload