xoxys.yum/tasks/yum_cron.yml

55 lines
1.5 KiB
YAML
Raw Normal View History

2018-11-15 20:38:39 +00:00
---
- block:
- name: Install yum-cron
package:
name: yum-cron
state: present
2018-11-15 20:38:39 +00:00
- name: Ensure yum-cron is enabled and running
service:
name: yum-cron
state: started
- name: Adjust yum-cron config file
template:
src: etc/yum/yum-cron.conf.j2
dest: /etc/yum/yum-cron.conf
owner: root
group: root
mode: 0644
notify: __yum_cron_restart
become: True
become_user: root
- block:
- name: Remove default cronjobs for yum-cron
file:
path: "{{ item }}"
state: absent
2019-08-27 06:32:50 +00:00
loop:
2018-11-15 20:38:39 +00:00
- /etc/cron.daily/0yum-daily.cron
- /etc/cron.hourly/0yum-hourly.cron
- name: Add custom cronjob for yum-cron
template:
src: etc/cron.d/x-yum.j2
dest: /etc/cron.d/x-yum
owner: root
group: root
mode: 0755
- name: Configure crontab to use custom yum-cron cronjob
cron:
2019-06-19 09:25:20 +00:00
name: "{{ yum_cron_custom_cronjob.name | default('yum-cron') }}"
minute: "{{ yum_cron_custom_cronjob.minute | default(0) }}"
hour: "{{ yum_cron_custom_cronjob.hour | default(4) }}"
2019-06-19 10:06:23 +00:00
day: "{{ yum_cron_custom_cronjob.day | default('*') }}"
weekday: "{{ yum_cron_custom_cronjob.weekday | default('*') }}"
month: "{{ yum_cron_custom_cronjob.month | default('*') }}"
2018-11-15 20:38:39 +00:00
user: root
cron_file: /etc/crontab
job: "/bin/sh /etc/cron.d/x-yum"
become: True
become_user: root
2019-06-19 09:25:20 +00:00
when: yum_cron_custom_cronjob.enabled | bool