Book Image

Mastering SaltStack

By : Joseph Hall
Book Image

Mastering SaltStack

By: Joseph Hall

Overview of this book

Table of Contents (19 chapters)
Mastering SaltStack
Credits
Foreword
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

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 web server can't serve pages if the firewall is blocking it, and...