Search code examples
scheduled-taskssalt-project

Salt schedule not executing function


I have the scheduler enabled on my salt master. I have a job that is configured to execute a runner function on a list of machines every month, like this example:

schedule:
  updater:
    args:
    - L@machine1,machine2,machine3
    cron: 0 * * * *
    enabled: true
    function: util.patch_selected
    jid_include: true
    maxrunning: 1
    name: updater

I've confirmed that the runner function (including the arguments) works fine on its own, however the scheduler does not execute the runner function. I've run salt-run saltutil.sync_runner on the master, and salt '*' saltutil.refresh_pillar on all the minions. What am I missing to get this running?


Solution

  • Running salt-run jobs.last_run target=<minion name> on the minion helped decipher the issue. It turns out that the "function" portion of a job schedule refers to a runner on the master, which doesn't work when targeting a minion. A workable solution for this was

    schedule:
      patch_updates:
        args: 
        - salt-call util.patch_selected
        cron: 0 * * * *
        enabled: true
        function: cmd.run
        jid_include: true
        maxrunning: 1
        name: patch_updates