Saltstack For DevOps
Saltstack For DevOps
Extremely fast and simple IT automation and configuration management
About the Book
Every book has a story, this story has a book
I wanted to resign from my job, my suggestions about working on creating a centralized configuration system have not been considered by the team leader. Worse than that, it was not something he really understood. Even my colleagues at that time didn't understand what is a configuration management system. At that time, "DevOps" wasn't a buzz word and folks in software engineering were not conscious about the power of what was coming next.
Like many of us, I'm lazy when it comes to repeating tasks manually but passionate when I automate them. Automation = Power.
I love automation, and in that previous job, there are hundreds of configuration files and thousands of variables to copy from text files then to adjust in some platforms, a huge number of poorly-configured servers, and hundreds of servers to manage by a very small team.. I wanted to work on the automation of some weekly procedures. I was aware that this is a good solution, but it was not the priority neither for the manager nor for the client. I'm talking about a role within a team of 14 people working on the integration of several heavy applications (mainly Java/Oracle, PHP/Mysql, Nginx, Python/Jython) with a complex architecture, tens of versions/environments to manage, and a critical infrastructure covering all the European continent. You can imagine how the word "change" can be seen as a horror movie for team leaders and decision-makers.
In the beginning, I was obliged to follow my boss's guidelines and the work methods my team has adopted, which have one goal: satisfying as fast as possible the unceasing demands of the client.
No, but .. wait, this is not satisfying for me!
I spent almost two weeks searching and working on some solutions before I convinced my boss to give me the time to set up an application prototype that will ease the heavy load, accelerate daily procedures and reduce human errors.
First, I created a configuration management tool using Python/Sqlite3, I spent weeks developing it and it was funny. Some weeks later, I discovered that a tool called Salt exists and found it then a good solution to replace my homemade platform. It meets the expectations of the integration process, or rather, the continuous integration, deployments, and automatic tests.
I hesitated between several alternatives: Ansible, Puppet, CFEngine, Chef .. etc. The choice was made based on several criteria (I was looking for robust, fast configuration management and remote execution tool that everybody can use without learning a new programming language) .. I have never regretted my choice. I found some difficulties. Let me admit: **many** difficulties. And honestly, when I started learning Salt, the official documentation was not as complete and good as now. I even still think the actual documentation can be better.
This book is the fruit of long hours of work and self-learning.
Well, in the beginning, I wanted to resign from my job, just a few days after discovering Salt, I was in love with it, and with what I was doing and learning. I tried Salt the first time when I saw my team taking more than 3 days (sometimes more) to configure hosted platforms at each deployment (we had more than 10 environments per application). After setting it up, the same procedure was taking less than 1/2 hour.
Through this book, it's your turn to discover SaltStack, and I will be your guide.
What are you going to learn?
You will learn how to:
- How to install and configure Salt
- How remote execution works in Salt
- How to describe your infrastructure and apps deployments using code
- How to create an event-based reactive infrastructure
- How to make automated changes to your data center following conditions you describe
- How to orchestrate your data center and app releases
- What are the best practices
- How to scale Salt when your infrastructure grows
- How to troubleshoot Salt
All examples in this book are tested.
The book comes with a free Salt Cheat Sheet.
Bundles that include this book
Reader Testimonials
Miguel Ángel
Very easy to understand
I'd like to tell you that you're doing an excellent job with this book.I've read all your posts related with Salt and all of them are very easy to understand for people that are beginners with these tools.
Nicola Senno
Nice work !
Antal Miksa
A good way to learn SaltStack
.. I haven't found enough resources online to learn Salt, but this book was a good way for me to learn many things ..
Loîc Erwan
For non english speakers
I don't have a good english, but I was able to learn Salt

Valentin Ouvrard
A great book on SaltStack.

Brandon James
Great book on Salt!!!
Table of Contents
Preface
- Every book has a story, this story has a book
- To whom is this book addressed?
- How to properly enjoy this guide
- About The Author
Overview and requirements
- Overview
- Requirements
- Python
- YAML
- Indentation
- Colons
- Dashes
- Jinja2
- SaltStack VS. Puppet VS. Chef VS. Ansible
Installation and configuration
- How Salt versioning works
- Supported OSs
- Installing Salt
- Ubuntu Focal (20)
- Redhat / CentOS 8 PY3
- Understanding the communication model
- Post installation configurations
- Salt master and minion identities
- Salt modules
- Introduction
- Salt execution modules
- Asynchronous execution
- Creating your custom modules
- Salt state modules.
- Salt execution modules vs. Salt state modules
- Asynchronous execution
- Outputter modules
- Salt Command Anatomy
- Runner modules
- Creating your own runner modules
Salt grains
- What are grains?
- Listing grains
- Creating custom grains
- Automating custom grains creation
Salt targeting
- Targeting is crucial
- Shell-style Globbing
- List matching
- Targeting with regex
- Targeting with grains
- Targeting with pillar
- Targeting by IP/subnet
- Compound Matchers
- Conclusion
Salt states
- Introduction
- Salt states: SLS
- Organizing SLS
- Extending Salt States
- Salt requisite system
- Putting everything together
- Statement of the Problem
- What are Salt renderers
- Using Jinja in YAML (and making your Salt states cross-platform)
- Updating your infrastructure states based on conditions
- Creating a system configuration dashboard using states, jinja, and grains
- Creating a reactive state
- States Execution and Output Formatter
- The problem and the solution
- What is a top file and when to use it
- Targeting using the top file
- Pillar vs. grains
- Listing pillar data
- Creating pillar data
- Pillar: advanced use cases
The Salt Mine
- When do we need Salt mine
- Hands-On Lab: Using Salt Mine
- Salt mine in practice
Salt formulas
- What are formulas
- How to use formulas from a remote gitfs
- How formulas are organized
- How to use formulas locally (recommended)
Agentless Salt
- Introduction
- Installation and requirements
- The roster file
- Using keys
- Configuring CLI options with Saltfile
- Using salt-ssh
Masterless Salt
- What is a masterless Salt?
- When to use masterless Salt?
- Installing and configuring a Salt master on the minion or what we call "salting the Salt master"
- Using salt-call commands on a system without a master
- Running states entirely from files local to the minion
- Bootstrapping the minion
- Running masterless States
Salt scheduling
- Introduction
- Scheduling jobs using states
- Scheduling jobs using modules
- Hands-on lab: Monitoring a web page speed using a scheduled job
- Advanced job scheduling
- Scheduling states
Salt Events
- The Salt event system
- Salt Event bus
- Event types
- Firing events
- Salt states events
Salt reactor
- What is Salt reactor?
- Associating events to reactors SLS files
- Working with reactors and reactor types
Salt beacons
- What are Salt beacons?
- Watching files with beacons
- Watching memory and CPU with beacons
- Alerting on Slack using beacons and reactors
Salt orchestration
- What is orchestration and why do we need it?
- Our first orchestration state
- A deeper dive into orchestration
- Applying an orchestration and a high state
Strategies for Scaling the Infrastructure
- Using Salt At Scale
- Too many minions authing at once
- Too many minions re-authing at once
- Too many minions re-connecting at once
- Too many minions returning at once
- Too few resources
- Masterless Salt
- Salt Syndic
- Using Salt At Scale
Troubleshooting
- General Troubleshooting and Prerequisites Checklist
- Troubleshooting salt-master
- Troubleshooting salt-minion
- Troubleshooting Ports
- Using salt-call
- Useful Commands
Best Practices
- Rules
- Using includes and extends in Salt states
- Conventions
- Following SLS namespace guidelines
- Organizing Grains
- Using the Documentation
- Follow the official conventions to write formulas
- Start your cheat sheet
- The usual lecture from the local system administrator
Final words
Salt Cheat Sheet
Code in this book
Other books by this author
The Leanpub 60-day 100% Happiness Guarantee
Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.
See full terms
Do Well. Do Good.
Authors have earned$11,817,855writing, publishing and selling on Leanpub, earning 80% royalties while saving up to 25 million pounds of CO2 and up to 46,000 trees.
Learn more about writing on Leanpub
Free Updates. DRM Free.
If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).
Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.
Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.
Learn more about Leanpub's ebook formats and where to read them
Top Books
Stratospheric
Tom Hombergs, Björn Wilmsmann, and Philip RiecksFrom Zero to Production with Spring Boot and AWS. All you need to know to get a Spring Boot application into production with AWS. No previous AWS knowledge required.
Go to stratospheric.dev for a tour of the contents.
C++20 - The Complete Guide
Nicolai M. JosuttisAll new language and library features of C++20 (for those who know previous C++ versions).
The book presents all new language and library features of C++20. Learn how this impacts day-to-day programming, to benefit in practice, to combine new features, and to avoid all new traps.
Buy early, pay less, free updates.
Other books:
OpenIntro Statistics
David Diez, Christopher Barr, Mine Cetinkaya-Rundel, and OpenIntroA complete foundation for Statistics, also serving as a foundation for Data Science.
Leanpub revenue supports OpenIntro (US-based nonprofit) so we can provide free desk copies to teachers interested in using OpenIntro Statistics in the classroom and expand the project to support free textbooks in other subjects.
More resources: openintro.org.
node-opcua by example
Etienne RossignonGet the best out of node-opcua through a set of documented examples by the author himself that will allow you to create stunning OPCUA Servers or Clients.
Advanced Web Application Architecture
Matthias NobackThe missing manual for making your web applications future-proof
Jetpack Compose internals
Jorge CastilloJetpack Compose is the future of Android UI. Master how it works internally and become a more efficient developer with it. You'll also find it valuable if you are not an Android dev. This book provides all the details to understand how the Compose compiler & runtime work, and how to create a client library using them.
Ansible for DevOps
Jeff GeerlingAnsible is a simple, but powerful, server and configuration management tool. Learn to use Ansible effectively, whether you manage one server—or thousands.
R Programming for Data Science
Roger D. PengThis book brings the fundamentals of R programming to you, using the same material developed as part of the industry-leading Johns Hopkins Data Science Specialization. The skills taught in this book will lay the foundation for you to begin your journey learning data science. Printed copies of this book are available through Lulu.
Thinking with Types
Sandy MaguireThis book aims to be the comprehensive manual for type-level programming. It's about getting you from here to there---from a competent Haskell programmer to one who convinces the compiler to do their work for them.
Maîtriser Apache JMeter
Philippe Mouawad, Bruno Demion (Milamber), and Antonio Gomes RodriguesToute la puissance d'Apache JMeter expliquée par ses commiteurs et utilisateurs experts. De l'intégration continue en passant par le Cloud, vous découvrirez comment intégrer JMeter à vos processus "Agile" et Devops.
If you're looking for the newer english version of this book, go to Master JMeter : From load testing to DevOps
Top Bundles
- #1
CCIE Service Provider Ultimate Study Bundle
2 Books
Piotr Jablonski, Lukasz Bromirski, and Nick Russo have joined forces to deliver the only CCIE Service Provider training resource you'll ever need. This bundle contains a detailed and challenging collection of workbook labs, plus an extensively detailed technical reference guide. All of us have earned the CCIE Service Provider certification... - #3
Software Architecture
2 Books
"Software Architecture for Developers" is a practical and pragmatic guide to modern, lightweight software architecture, specifically aimed at developers. You'll learn:The essence of software architecture.Why the software architecture role should include coding, coaching and collaboration.The things that you really need to think about before... - #4
Pattern-Oriented Memory Forensics and Malware Detection
2 Books
This training bundle for security engineers and researchers, malware and memory forensics analysts includes two accelerated training courses for Windows memory dump analysis using WinDbg. It is also useful for technical support and escalation engineers who analyze memory dumps from complex software environments and need to check for possible... - #5
Practical FP in Scala + Functional event-driven architecture
2 Books
Practical FP in Scala (A hands-on approach) & Functional event-driven architecture, aka FEDA, (Powered by Scala 3), together as a bundle! The content of PFP in Scala is a requirement to understand FEDA so why not take advantage of this bundle!? - #10
Cloud Architect: Transform Technology and Organization
2 Books
Architects don't just recite product names and features. They understand the options, decisions, and trade-offs behind them. They earn credibility and maintain authenticity by connecting the penthouse with the engine room. Get two essential books that redefine the role of the software and IT architect at one low price:37 Things One Architect...