4

I would like to schedule a highstate to run every night but not in parallel. Is there a way to add batch option to the scheduling system?

Example:

schedule:
  highstate:
    enabled: True
    function: state.highstate
    maxrunning: 1
    when: 3:00am
    kwargs:
      batch: 1

Ideally I would like to also randomize the time when it runs. I guess I could schedule to run every two hours within one hour time range so it will run only once:

schedule:
  highstate:
    enabled: True
    function: state.highstate
    maxrunning: 1
    range:
      start: 3:00am
      end: 4:00am
    hours: 2
    kwargs:
      batch: 1
3
+25

When initiating a highstate from the master you can utilize a feature known as batch mode.

The --batch-size flag allows you to specify how many minions to run against in parallel. You can use the command below:

salt --batch-size 1 '*' state.highstate

Regarding the time when it runs, you can use splay argument like the following:

splay:
  start: 10
  end: 15

This will splay the time between 10 and 15 seconds

If you want to use it with a scheduling system:

Edit /etc/anacrontab and add RANDOM DELAY and START_HOURS_RANGE parameters:

# The maximal random delay added to the base delay of the jobs
RANDOM_DELAY=60
# interval, when scheduled jobs can be run, in hours
START_HOURS_RANGE=3-4

1 10 update.daily /usr/bin/salt --batch-size 1 '*' state.highstate

  • Thanks for your reply but this doesn't solve my problem. I'm aware about batch mode but my question is how to use it with scheduling system. Splay only works with time intervals (minutes, hours etc.) but my requirement is so it runs between specified time range (3am-4am, day 1: 3:15am, day 2: 3:25am etc.). – HTF Jan 4 '16 at 10:59
  • I edited my answer, check it out – Alaa Chatti Jan 4 '16 at 13:23
  • I ment [SaltStack scheduling system] [1] but thanks for alternative solution.[1]: docs.saltstack.com/en/latest/topics/jobs/#scheduling-jobs – HTF Jan 5 '16 at 8:04
  • Yes I see what you mean but what you need can't be done using salt stack scheduling system. Feel free to validate my answer :-) – Alaa Chatti Jan 5 '16 at 9:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.