From b4cdea984e777c0874ddcde033c5107fbc5aea3a Mon Sep 17 00:00:00 2001 From: Hyperling Date: Tue, 14 Oct 2025 11:09:24 -0700 Subject: [PATCH] Add sleep to ansible-pull commands. Change weekly force to daily. Use explicit command rather than rarely used file. --- tasks/general/cron/ansible.yml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/tasks/general/cron/ansible.yml b/tasks/general/cron/ansible.yml index 907041e..f68cb45 100644 --- a/tasks/general/cron/ansible.yml +++ b/tasks/general/cron/ansible.yml @@ -1,12 +1,18 @@ --- # Jobs relating to the ansible user. +# $RANDOM is anywhere from 0 to 32767 in BASH. This would be up to ~9 hours. +# $RANDOM / 10 can be up to about 3200 seconds, or ~55 minutes. +# $RANDOM / 20 can be up to about 1600 seconds, or ~27 minutes. +# $RANDOM / 50 can be up to about 650 seconds, or ~11 minutes. +# $RANDOM / 100 can be up to about 320 seconds, or ~5 minutes. +# This prevents multiple systems from hitting it at the exact same time. - name: General | Cron | Ansible | Create Subscriber Job cron: user: ansible name: "Ansible Sync" minute: "*/30" - job: "sudo {{ ansible_pull_exec.stdout }} -v -o -U {{ git_repo_http }} --checkout {{ branch }}" + job: "sleep $(( $RANDOM / 20 )); sudo {{ ansible_pull_exec.stdout }} -v -o -U {{ git_repo_http }} --checkout {{ branch }}" state: present disabled: "{{ 'yes' if no_telem else 'no' }}" @@ -14,7 +20,7 @@ cron: user: ansible name: "Ansible Weekly Forced Sync" - special_time: weekly - job: "{{ user_root.home }}/bin/scm.sh" + special_time: daily + job: "sleep $(( $RANDOM / 1 )); sudo {{ ansible_pull_exec.stdout }} -v -U {{ git_repo_http }} --checkout {{ branch }}" state: present disabled: "{{ 'yes' if no_telem else 'no' }}"