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

The SLS efficiency


When building an SLS tree, the directory structure is only part of the equation. There are a number of strategies that can be employed in the SLS files, which will increase their ease of use and maintainability.

Includes and extends

Like a number of modern languages and file formats, SLS files were designed to take advantage of code reuse. Rather than creating large, monolithic files, states can be broken down into smaller files, which can be combined together across multiple environments.

Consider the following partial SLS file:

iptables: 
  service: 
    - dead 
httpd: 
  pkg: 
    - installed 
  service: 
    - running 
/opt/codebase: 
  file.recurse: 
    - source: salt://codebase/files 

Obviously, a production version of this would be far longer, but this short version fits our needs.

There are three distinct components of this SLS: the firewall, the web server, and the code base. There is an implied order here: the...