Book Image

Mastering SaltStack - Second Edition

Book Image

Mastering SaltStack - Second Edition

Overview of this book

SaltStack is a powerful configuration management and automation suite designed to manage servers and tens of thousands of nodes. This book showcases Salt as a very powerful automation framework. We will review the fundamental concepts to get you in the right frame of mind, and then explore Salt in much greater depth. You will explore Salt SSH as a powerful tool and take Salt Cloud to the next level. Next, you’ll master using Salt services with ease in your infrastructure. You will discover methods and strategies to scale your infrastructure properly. You will also learn how to use Salt as a powerful monitoring tool. By the end of this book, you will have learned troubleshooting tips and best practices to make the entire process of using Salt pain-free and easy.
Table of Contents (20 chapters)
Mastering SaltStack Second Edition
Credits
Foreword
About the Author
About the Reviewer
www.PacktPub.com
Preface

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:

  1. Request a new cloud server.

  2. Upon its creation, kick off a test suite to validate the servers.

  3. If the tests fail, fire an alert and stop.

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