From ed8887e5be761d9efb587dc0bb3011ff6e080907 Mon Sep 17 00:00:00 2001 From: Christoph Date: Fri, 17 Jul 2026 18:24:56 +0200 Subject: [PATCH] Add debug task to display cron variables and improve formatting in cron.yml --- roles/common/tasks/cron.yml | 59 +++++++++++++++++++++---------------- 1 file changed, 34 insertions(+), 25 deletions(-) diff --git a/roles/common/tasks/cron.yml b/roles/common/tasks/cron.yml index 62e6a26..97c491e 100644 --- a/roles/common/tasks/cron.yml +++ b/roles/common/tasks/cron.yml @@ -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 ansible.builtin.set_fact: @@ -48,7 +58,7 @@ dest: /var/spool/cron/crontabs/root owner: root group: crontab - mode: '0600' + mode: "0600" content: | # Edit this file to introduce tasks to be run by cron. # @@ -79,46 +89,45 @@ - name: (cron.yml) Set env entries in user crontabs cron: - name: '{{ item.name }}' - env: 'yes' - user: '{{ item.user | default("root", true) }}' - job: '{{ item.job }}' - insertafter: '{{ item.insertafter | default(omit) }}' - loop: "{{ cron_env_entries }}" + name: "{{ item.name }}" + env: "yes" + user: '{{ item.user | default("root") }}' + job: "{{ item.job }}" + insertafter: "{{ item.insertafter | default(omit) }}" + loop: "{{ cron_env_entries | default([]) }}" loop_control: - label: '{{ item.name }}' + label: "{{ item.name }}" when: item.job is defined tags: - user_crontab - - name: (cron.yml) Set special time entries in user crontabs cron: - name: '{{ item.name }}' - special_time: '{{ item.special_time }}' - user: '{{ item.user | default("root", true) }}' - job: '{{ item.job }}' + name: "{{ item.name }}" + special_time: "{{ item.special_time }}" + user: '{{ item.user | default("root") }}' + job: "{{ item.job }}" state: present - loop: "{{ cron_user_special_time_entries }}" + loop: "{{ cron_user_special_time_entries | default([]) }}" loop_control: - label: '{{ item.name }}' + label: "{{ item.name }}" when: item.job is defined tags: - user_crontab - - name: (cron.yml) Set normal entries in user crontabs cron: - name: '{{ item.name }}' - minute: '{{ item.minute | default(omit) }}' - hour: '{{ item.hour | default("root", true) }}' - day: '{{ day | default(omit) }}' - weekday: '{{ item.weekday | default(omit) }}' - month: '{{ item.month | default(omit) }}' - job: '{{ item.job }}' - loop: "{{ cron_user_entries }}" + name: "{{ item.name }}" + minute: "{{ item.minute | default(omit) }}" + hour: "{{ item.hour | default(omit) }}" + day: "{{ item.day | default(omit) }}" + weekday: "{{ item.weekday | default(omit) }}" + month: "{{ item.month | default(omit) }}" + user: '{{ item.user | default("root") }}' + job: "{{ item.job }}" + loop: "{{ cron_user_entries | default([]) }}" loop_control: - label: '{{ item.name }}' + label: "{{ item.name }}" when: item.job is defined tags: - user_crontab