1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
--- # tasks file for cron - name: include assert.yml include_tasks: assert.yml run_once: yes - name: install cron package: name: "{{ cron_packages }}" state: present - name: configure shell lineinfile: path: "{{ cron_configuration }}" line: "SHELL={{ cron_shell }}" regexp: "^SHELL" create: yes mode: "0644" notify: - restart cron - name: configure path lineinfile: path: "{{ cron_configuration }}" line: "PATH={{ cron_path }}" regexp: "^PATH" create: yes mode: "0644" notify: - restart cron - name: configure mailto lineinfile: path: "{{ cron_configuration }}" line: "MAILTO={{ cron_mailto }}" regexp: "^MAILTO" create: yes mode: "0644" notify: - restart cron - name: start and enable cron service: name: "{{ cron_service }}" state: started enabled: yes when: - cron_service | length - name: schedule requested cron jobs cron: name: "{{ item.name }}" minute: "{{ item.minute | default(omit) }}" hour: "{{ item.hour | default(omit) }}" day: "{{ item.day | default(omit) }}" month: "{{ item.month | default(omit) }}" weekday: "{{ item.weekday | default(omit) }}" job: "{{ item.job }}" state: "{{ item.state | default('present') }}" user: "{{ item.user | default(omit) }}" loop: "{{ cron_jobs }}" loop_control: label: "{{ item.name }}" notify: - restart cron when: - cron_jobs is defined