2022-04-08 14:01:13 +02:00
|
|
|
---
|
2022-10-15 16:09:45 +02:00
|
|
|
- name: Check if rclone is installed
|
|
|
|
command: which rclone
|
|
|
|
changed_when: false
|
|
|
|
failed_when: rclone_installed.rc not in [0,1]
|
|
|
|
register: rclone_installed
|
|
|
|
|
|
|
|
- name: Install rclone first!
|
|
|
|
fail:
|
|
|
|
msg: "rclone is not installed, install it first"
|
|
|
|
when: rclone_installed.rc not in [ 0 ]
|
2022-04-08 14:01:13 +02:00
|
|
|
|
|
|
|
- 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
|