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

Get Mastering SaltStack - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.