From fd344fd385df275cfcfa5f01ac89461715259f93 Mon Sep 17 00:00:00 2001 From: Ryan Cavicchioni Date: Sun, 10 Nov 2019 15:36:23 -0600 Subject: [PATCH] Add rclone role --- roles/rclone/defaults/main.yaml | 9 ++++++ roles/rclone/tasks/Debian.yaml | 5 ++++ roles/rclone/tasks/main.yaml | 41 +++++++++++++++++++++++++++ roles/rclone/templates/rclone.conf.j2 | 6 ++++ roles/rclone/vars/Debian.yaml | 2 ++ 5 files changed, 63 insertions(+) create mode 100644 roles/rclone/defaults/main.yaml create mode 100644 roles/rclone/tasks/Debian.yaml create mode 100644 roles/rclone/tasks/main.yaml create mode 100644 roles/rclone/templates/rclone.conf.j2 create mode 100644 roles/rclone/vars/Debian.yaml diff --git a/roles/rclone/defaults/main.yaml b/roles/rclone/defaults/main.yaml new file mode 100644 index 0000000..f2696af --- /dev/null +++ b/roles/rclone/defaults/main.yaml @@ -0,0 +1,9 @@ +--- +rclone_package_name: rclone +rclone_package_state: present + +rclone_config_path: /etc/rclone + +rclone_config: [] + +rclone_cron: [] diff --git a/roles/rclone/tasks/Debian.yaml b/roles/rclone/tasks/Debian.yaml new file mode 100644 index 0000000..69bf52b --- /dev/null +++ b/roles/rclone/tasks/Debian.yaml @@ -0,0 +1,5 @@ +--- +- name: install package + apt: + deb: "{{ rclone_package_url }}" + diff --git a/roles/rclone/tasks/main.yaml b/roles/rclone/tasks/main.yaml new file mode 100644 index 0000000..be8cac6 --- /dev/null +++ b/roles/rclone/tasks/main.yaml @@ -0,0 +1,41 @@ +--- +- name: gather OS specific variables + include_vars: "{{ item }}" + with_first_found: + - "{{ ansible_distribution }}-{{ ansible_distribution_major_version }}.yaml" + - "{{ ansible_distribution }}.yaml" + - "{{ ansible_os_family }}.yaml" + +- name: OS specific tasks + include: "{{ item }}" + with_first_found: + - "{{ ansible_distribution }}-{{ ansible_distribution_major_version }}.yaml" + - "{{ ansible_distribution }}.yaml" + - "{{ ansible_os_family }}.yaml" + +- name: create configuration directory + file: + path: "{{ rclone_config_path }}" + state: directory + +- name: configure + template: + src: rclone.conf.j2 + dest: "{{ rclone_config_path }}/{{ item.name }}.conf" + owner: "{{ item.owner | default('root') }}" + group: "{{ item.group | default('root') }}" + mode: "{{ item.mode | default('0600') }}" + with_items: "{{ rclone_config }}" + +- name: cron jobs + cron: + name: "{{ item.name }}" + user: "{{ item.user | default('root') }}" + minute: "{{ item.minute | default(omit) }}" + hour: "{{ item.hour | default(omit) }}" + day: "{{ item.day | default(omit) }}" + month: "{{ item.month | default(omit) }}" + weekday: "{{ item.weekday | default(omit) }}" + job: "{{ item.job }}" + state: "{{ item.state | default('present') }}" + with_items: "{{ rclone_cron }}" diff --git a/roles/rclone/templates/rclone.conf.j2 b/roles/rclone/templates/rclone.conf.j2 new file mode 100644 index 0000000..041d21c --- /dev/null +++ b/roles/rclone/templates/rclone.conf.j2 @@ -0,0 +1,6 @@ +# {{ ansible_managed }} + +[{{ item.name }}] +type = {{ item.type }} +account = {{ item.account }} +key = {{ item.key }} diff --git a/roles/rclone/vars/Debian.yaml b/roles/rclone/vars/Debian.yaml new file mode 100644 index 0000000..e9986bd --- /dev/null +++ b/roles/rclone/vars/Debian.yaml @@ -0,0 +1,2 @@ +--- +rclone_package_url: https://downloads.rclone.org/v1.50.1/rclone-v1.50.1-linux-amd64.deb