Add debug task to display cron variables and improve formatting in cron.yml
This commit is contained in:
+34
-25
@@ -1,4 +1,14 @@
|
|||||||
---
|
---
|
||||||
|
- name: (cron.yml) Debug - Show cron variables
|
||||||
|
ansible.builtin.debug:
|
||||||
|
msg: |
|
||||||
|
inventory_hostname: {{ inventory_hostname }}
|
||||||
|
ansible_host: {{ ansible_host | default('not set') }}
|
||||||
|
cron_env_entries: {{ cron_env_entries | default([]) }}
|
||||||
|
cron_user_special_time_entries: {{ cron_user_special_time_entries | default([]) }}
|
||||||
|
cron_user_entries: {{ cron_user_entries | default([]) }}
|
||||||
|
tags:
|
||||||
|
- user_crontab
|
||||||
|
|
||||||
- name: (cron.yml) Define candidate paths for root crontab PATH
|
- name: (cron.yml) Define candidate paths for root crontab PATH
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
@@ -48,7 +58,7 @@
|
|||||||
dest: /var/spool/cron/crontabs/root
|
dest: /var/spool/cron/crontabs/root
|
||||||
owner: root
|
owner: root
|
||||||
group: crontab
|
group: crontab
|
||||||
mode: '0600'
|
mode: "0600"
|
||||||
content: |
|
content: |
|
||||||
# Edit this file to introduce tasks to be run by cron.
|
# Edit this file to introduce tasks to be run by cron.
|
||||||
#
|
#
|
||||||
@@ -79,46 +89,45 @@
|
|||||||
|
|
||||||
- name: (cron.yml) Set env entries in user crontabs
|
- name: (cron.yml) Set env entries in user crontabs
|
||||||
cron:
|
cron:
|
||||||
name: '{{ item.name }}'
|
name: "{{ item.name }}"
|
||||||
env: 'yes'
|
env: "yes"
|
||||||
user: '{{ item.user | default("root", true) }}'
|
user: '{{ item.user | default("root") }}'
|
||||||
job: '{{ item.job }}'
|
job: "{{ item.job }}"
|
||||||
insertafter: '{{ item.insertafter | default(omit) }}'
|
insertafter: "{{ item.insertafter | default(omit) }}"
|
||||||
loop: "{{ cron_env_entries }}"
|
loop: "{{ cron_env_entries | default([]) }}"
|
||||||
loop_control:
|
loop_control:
|
||||||
label: '{{ item.name }}'
|
label: "{{ item.name }}"
|
||||||
when: item.job is defined
|
when: item.job is defined
|
||||||
tags:
|
tags:
|
||||||
- user_crontab
|
- user_crontab
|
||||||
|
|
||||||
|
|
||||||
- name: (cron.yml) Set special time entries in user crontabs
|
- name: (cron.yml) Set special time entries in user crontabs
|
||||||
cron:
|
cron:
|
||||||
name: '{{ item.name }}'
|
name: "{{ item.name }}"
|
||||||
special_time: '{{ item.special_time }}'
|
special_time: "{{ item.special_time }}"
|
||||||
user: '{{ item.user | default("root", true) }}'
|
user: '{{ item.user | default("root") }}'
|
||||||
job: '{{ item.job }}'
|
job: "{{ item.job }}"
|
||||||
state: present
|
state: present
|
||||||
loop: "{{ cron_user_special_time_entries }}"
|
loop: "{{ cron_user_special_time_entries | default([]) }}"
|
||||||
loop_control:
|
loop_control:
|
||||||
label: '{{ item.name }}'
|
label: "{{ item.name }}"
|
||||||
when: item.job is defined
|
when: item.job is defined
|
||||||
tags:
|
tags:
|
||||||
- user_crontab
|
- user_crontab
|
||||||
|
|
||||||
|
|
||||||
- name: (cron.yml) Set normal entries in user crontabs
|
- name: (cron.yml) Set normal entries in user crontabs
|
||||||
cron:
|
cron:
|
||||||
name: '{{ item.name }}'
|
name: "{{ item.name }}"
|
||||||
minute: '{{ item.minute | default(omit) }}'
|
minute: "{{ item.minute | default(omit) }}"
|
||||||
hour: '{{ item.hour | default("root", true) }}'
|
hour: "{{ item.hour | default(omit) }}"
|
||||||
day: '{{ day | default(omit) }}'
|
day: "{{ item.day | default(omit) }}"
|
||||||
weekday: '{{ item.weekday | default(omit) }}'
|
weekday: "{{ item.weekday | default(omit) }}"
|
||||||
month: '{{ item.month | default(omit) }}'
|
month: "{{ item.month | default(omit) }}"
|
||||||
job: '{{ item.job }}'
|
user: '{{ item.user | default("root") }}'
|
||||||
loop: "{{ cron_user_entries }}"
|
job: "{{ item.job }}"
|
||||||
|
loop: "{{ cron_user_entries | default([]) }}"
|
||||||
loop_control:
|
loop_control:
|
||||||
label: '{{ item.name }}'
|
label: "{{ item.name }}"
|
||||||
when: item.job is defined
|
when: item.job is defined
|
||||||
tags:
|
tags:
|
||||||
- user_crontab
|
- user_crontab
|
||||||
|
|||||||
Reference in New Issue
Block a user