By using the
jobs runner, we can further view and manipulate our jobs; in other words, most actions that take place on our master and minions. Additionally, we can take a step closer towards proper orchestration by using the jobs scheduler to assign highstates, state runs, runner runs, and more at specific times or using specific credentials.
To see this in action, let's schedule a highstate. This will highstate our servers once every minute (if that seems like a lot, don't worry as we'll remove it shortly):
$ sudo salt 'minion*' schedule.add highstate-1 function='state.highstate' seconds=60
In this instance,
highstate-1 is a name we gave to the job. This can be anything we want.
Now we can connect to our event bus and wait:
$ sudo salt-run state.event pretty=true
After a minute, we'll start receiving information about the jobs run during our highstate. Unfortunately, enforcing our states once every minute is a little excessive.
Close the event bus with a CTRL+C and remove the scheduled job:
$ sudo salt 'minion*' schedule.delete highstate-1
This is just one way of setting a schedule. If we wanted to do this via pillar data or minion config we would use:
schedule: highstate: function: state.highstate minutes: 30
In this instance, it schedules the highstate every thirty minutes.
If adding to pillar, also remember to map it to the appropriate minions:
base: 'minion*': - mysql - beacons - schedule