ansible-maintenance/tasks/restart.yml

14 lines
425 B
YAML
Raw Normal View History

2025-02-04 23:54:18 +01:00
- name: schedule restart randomly between 5-7 AM if necessary
2024-09-25 17:53:35 +02:00
shell: |
hour=$(shuf -i 5-6 -n 1)
2024-09-25 17:53:35 +02:00
minute=$(shuf -i 0-59 -n 1)
shutdown -r "$hour:$minute"
echo "restart scheduled for $hour:$minute"
when: restart_needed.stdout_lines | length > 0
register: restard_scheduled
- name: output "restart schedule"
debug:
var: restard_scheduled.stdout_lines
when: restart_needed.stdout_lines | length > 0