saltstack/salt — pull request #12315 by UtahDave (2014-04-26 03:46:59+00:00)
Title: Add a queue system to Salt

This PR adds a queue subsystem to Salt. This allows infrastructure actions to be queued up and executed at a desired interval or initiated through a runner. The default queue backend is sqlite3. Support for AWS SQS and other queues will be added in the future.

salt/queues/sqlite_queue.py does the actual work of interacting with the sqlite databases. Additional plugins for SQS or Redis queues will get added to this same directory.

There is a new runner named queue.py salt/runners/queue.py is the generic interface for interacting with the queues. Adding an item to a queue or processing a queue will happen with salt/runners/queue.py regardless of the queue backend used. Queues are created automatically if they don't already exist.

In the following example we add a minion id of 'minion01' to the 'delete_keys' queue, which is an sqlite backend.
```
salt-run queue.insert sqlite delete_keys minion01
salt-run queue.process_queue sqlite delete_keys all
```

When `salt-run queue.process_queue` is called an event is created on the Salt Event bus with a tag of 'salt/queue/delete_keys/process'. If we create a Salt Reactor to watch for that tag, then we can do anything we want within the Reactor sls with the list of one or more minion IDs that we popped from the queue.

The queue api is not stable yet.