Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cron job task fails to remove cron job if setting changed from present to absent #1

Open
kfiresmith opened this issue May 9, 2024 · 0 comments

Comments

@kfiresmith
Copy link
Owner

The when: logic on the cron job task is all wrong.

Corrected task is:

- name: Manage cron job presence and settings
  ansible.builtin.cron:
    name: scheduled-reboot
    cron_file: scheduled-reboot
    user: root
    job: 'PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin /usr/local/bin/scheduled-reboot'
    state: "{{ scheduled_reboot_cronjob_state }}"
    minute: "{{ reboot_schedule.split(' ')[0] }}"
    hour: "{{ reboot_schedule.split(' ')[1] }}"
    day: "{{ reboot_schedule.split(' ')[2] }}"
    month: "{{ reboot_schedule.split(' ')[3] }}"
    weekday: "{{ reboot_schedule.split(' ')[4] }}"
  when: reboot_schedule is defined and scheduled_reboot_cronjob_state is defined
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant