Using reactors with Salt Cloud
Salt Cloud is powerful on its own, but it can be made even more powerful by tying it in Salt's own event bus. Let's go ahead and set up a workflow to kick off whenever a new server is spun up using Salt Cloud. The steps that we need to perform, in order, are as follows:
Request a new cloud server.
Upon its creation, kick off a test suite to validate the servers.
If the tests fail, fire an alert and stop.
If they succeed, add the server to the load balancer.
We won't create a full test suite here as that is well beyond the scope of this book. However, because we can make use of Jinja templates, we will go ahead and perform some configuration for the load balancer.
Setting up the event tags
We're going to use a combination of both standard cloud tags and our own custom tags in our example. Go ahead and edit the master
configuration file, and add a reactor
section:
reactor: # Look for new web servers - 'salt/cloud/web-*/created': # Start the...