4

I have multiple salt states and commands which are executed while other jobs could currently running.

Then I get an error for new jobs, something like:

The function "state.apply" is running as PID 3869 and was started at 2017, Mar 23 10:19:32.691177 with jid 20170323101932691177

Is there a way to wait for other jobs to complete first or to run the job in parallel?

OrangeDog
  • 36,653
  • 12
  • 122
  • 207
imehl
  • 789
  • 1
  • 9
  • 25

3 Answers3

5

You can queue the execution of salt states: salt minion_A state.apply some.state queue=True

This will queue the state if any other states are currently running, keep in mind that this option starts a new thread for each queued state run, so use this option sparingly (https://docs.saltstack.com/en/latest/ref/modules/all/salt.modules.state.html).

Alex Zel
  • 660
  • 2
  • 12
  • 27
0

You could use the saltutil.running function to check if there is a salt job running on a minion, f.e.

salt 'MINION' saltutil.running

See https://docs.saltstack.com/en/latest/ref/modules/all/salt.modules.saltutil.html#salt.modules.saltutil.running

Florian
  • 21
  • 3
0

As of salt version 2017.7.0, you can add parallel=true to your state command, which will attempt to execute tasks in parallel.