From d1cd0b73d190bf7e21b984394540c4f01a15a1e4 Mon Sep 17 00:00:00 2001 From: Robert Kaussow Date: Sat, 1 Aug 2020 21:44:58 +0200 Subject: [PATCH] add conjob option --- defaults/main.yml | 14 ++++++++++++++ tasks/setup.yml | 29 +++++++++++++++++++++-------- 2 files changed, 35 insertions(+), 8 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index 01ccc9c..5526251 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -31,3 +31,17 @@ minio_access_key: "demo" # @var minio_secret_key:description: Minio secret key (should be changed for prod environments) minio_secret_key: "passphrase" + +minio_cronjobs: [] +# @var minio_cronjobs:example: > +# minio_cronjobs: +# - name: maintenance +# minute: "0" +# hour: "0" +# day: "*" +# month: "*" +# weekday: "*" +# job: "mc rm --older-than 30d --recursive --force my_bucket/logs" +# user: "{{ minio_user }}" +# cron_file: "minio" +# @end diff --git a/tasks/setup.yml b/tasks/setup.yml index a2c43b6..b0dbd7c 100644 --- a/tasks/setup.yml +++ b/tasks/setup.yml @@ -25,15 +25,28 @@ become: True become_user: "{{ minio_user }}" -- name: Download Minio client - get_url: - url: "{{ __minio_client_source }}{{ '/' + minio_client_version if minio_client_version != 'latest' else '/mc' }}" - dest: "/usr/local/bin/mc" - mode: 0755 - become: True - become_user: root - - block: + - name: Download Minio client + get_url: + url: "{{ __minio_client_source }}{{ '/' + minio_client_version if minio_client_version != 'latest' else '/mc' }}" + dest: "/usr/local/bin/mc" + mode: 0755 + + - name: Create cronjobs + cron: + name: "{{ item.name }}" + minute: "{{ item.minute | default('*') }}" + hour: "{{ item.hour | default('*') }}" + day: "{{ item.day | default('*') }}" + month: "{{ item.month | default('*') }}" + weekday: "{{ item.weekday | default('*') }}" + job: "{{ item.job }}" + user: "{{ item.user | default(omit) }}" + cron_file: "{{ item.cron_file | default(omit) }}" + loop: "{{ minio_cronjobs }}" + loop_control: + label: "{{ item.name }}" + - name: Copy sysconfig file template: src: "etc/sysconfig/minio.j2"