Jobs

Length: 00:06:50

Lesson Summary:

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.

Schedule a Highstate

  1. 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.

  2. 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.

  3. 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


This lesson is only available to Linux Academy members.

Sign Up To View This Lesson
Or Log In

Looking For Team Training?

Learn More