ansible-roles/ghn-gcore/ghn-gcore-maintenance/tasks/main.yml

62 lines
2.4 KiB
YAML

---
- block:
- name: Install a cron job that restarts the registry gCore service
cron: name="Restart the {{ item.user }} gCore service"
minute="{{ item.minute | default(0) }}"
hour="{{ item.hour | default(3) }}"
weekday="{{ item.weekday | default('*') }}"
day="{{ item.day | default('*') }}"
user="{{ item.user }}"
job="{{ item.job }}"
disabled="{{ item.disabled | default(False) }}"
with_items: '{{ gcore_maintenance_cron_users }}'
when: gcore_maintenance_restart_cron
tags: [ 'gcoreboot', 'gcore_cron' ]
- block:
- name: Remove the cron job that restarts the registry gCore service
cron: name="Restart the {{ item.user }} gCore service"
minute="{{ item.minute | default(0) }}"
hour="{{ item.hour | default(3) }}"
weekday="{{ item.weekday | default('*') }}"
day="{{ item.day | default('*') }}"
user="{{ item.user }}"
job="{{ item.job }}"
disabled="{{ item.disabled | default(False) }}"
state=absent
with_items: '{{ gcore_maintenance_cron_users }}'
when: not gcore_maintenance_restart_cron
tags: [ 'gcoreboot', 'gcore_cron' ]
- block:
- name: Install the log cleanup script
copy: src=clean_access_log.sh dest={{ gcore_maintenance_log_files_cleanup_script }} mode=0755 owner=root group=root
- name: Install a cron job that removes the old log files
cron: name="Cleanup the {{ item.user }} gCore log files"
special_time='daily'
user="{{ item.user }}"
job="{{ item.logrotate_job }}"
disabled="{{ item.disabled | default(False) }}"
with_items: '{{ gcore_maintenance_cron_users }}'
when: item.logrotate_job is defined
when: gcore_maintenance_log_files_cleanup
tags: [ 'gcoreboot', 'gcore_cron', 'gcore_logs' ]
- block:
- name: Remove the cron job that restarts the registry gCore service
cron: name="Cleanup the {{ item.user }} gCore log files"
special_time='daily'
user="{{ item.user }}"
job="{{ item.logrotate_job }}"
disabled="{{ item.disabled | default(False) }}"
state=absent
with_items: '{{ gcore_maintenance_cron_users }}'
when: item.logrotate_job is defined
when: not gcore_maintenance_log_files_cleanup
tags: [ 'gcoreboot', 'gcore_cron', 'gcore_logs' ]