diff --git a/roles/ara_api/defaults/main.yaml b/roles/ara_api/defaults/main.yaml index 077387e..65bc540 100644 --- a/roles/ara_api/defaults/main.yaml +++ b/roles/ara_api/defaults/main.yaml @@ -204,3 +204,16 @@ ara_api_database_conn_max_age: 0 # timezone but Ansible doesn't provide, for example, an ansible_timezone fact # that we could use here. With that in mind, UTC is the best default for now. ara_api_time_zone: UTC + +# ARA cleanup settings +# The following settings configure daily maintenance cronjobs +ara_api_configure_cron: false + +# When configuring cronjobs, only provide the arguments for the ara CLI utility +ara_api_cleanup_crons: + - name: ara_api expire running playbooks + arguments: 'expire --server http://localhost:8000 --client http --confirm --hours 24' + special_time: 'daily' # you can also use other time arguments from the cron module + - name: ara_api prune old reports + arguments: 'playbook prune --server http://localhost:8000 --client http --confirm --days 30' + special_time: 'daily' diff --git a/roles/ara_api/tasks/config.yaml b/roles/ara_api/tasks/config.yaml index 4af53bc..597a3b7 100644 --- a/roles/ara_api/tasks/config.yaml +++ b/roles/ara_api/tasks/config.yaml @@ -110,3 +110,18 @@ notify: - restart ara-api no_log: "{{ ara_api_secure_logging }}" + +- name: Set up ARA API cronjobs + cron: + name: "{{ job['name'] }}" + special_time: "{{ job['special_time'] | default(omit) }}" + minute: "{{ job['minute'] | default(omit) }}" + hour: "{{ job['hour'] | default(omit) }}" + day: "{{ job['day'] | default(omit) }}" + weekday: "{{ job['weekday'] | default(omit) }}" + month: "{{ job['month'] | default(omit) }}" + job: "{{ ara_api_venv_path }}/bin/ara {{ job['arguments'] }} >/dev/null 2>&1" + loop: "{{ ara_api_cleanup_crons }}" + loop_control: + loop_var: 'job' + when: ara_api_configure_cron