xoxys.yum/tasks/yum_cron.yml

52 lines
1.1 KiB
YAML
Raw Normal View History

2018-11-15 20:38:39 +00:00
---
- block:
- name: Install yum-cron
package:
name: yum-cron
state: latest
- 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
with_items:
- /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:
name: yum-cron
minute: 0
hour: 3
user: root
cron_file: /etc/crontab
job: "/bin/sh /etc/cron.d/x-yum"
become: True
become_user: root
when: yum_cron_custom_cronjob