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
80% Royalties. Earn $16 on a $20 book.
We pay 80% royalties. That's not a typo: you earn $16 on a $20 sale. If we sell 5000 non-refunded copies of your book or course for $20, you'll earn $80,000.
(Yes, some authors have already earned much more than that on Leanpub.)
In fact, authors have earned$12,307,240writing, publishing and selling on Leanpub.
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
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.
Personal Finance
Jason AndersonThis textbook provides an in-depth analysis on personal finance that is both practical and straightforward in its approach. It has been written in such a way that the readers can gain knowledge without getting overwhelmed by the technical terms. Suitable for both beginners and advanced learners.
Getting to Know IntelliJ IDEA
Trisha Gee and Helen ScottIf we treat our IDE as a text editor, we are doing ourselves a disservice. Using a combination of tutorials and a questions-and-answers approach, Getting to Know IntelliJ IDEA will help you find ways to use IntelliJ IDEA that enable you to work comfortably and productively as a professional developer.
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:
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.
Mastering STM32 - Second Edition
Carmine NovielloWith more than 1200 microcontrollers, STM32 is probably the most complete ARM Cortex-M platform on the market. This book aims to be the most complete guide around introducing the reader to this exciting MCU portfolio from ST Microelectronics and its official CubeHAL and STM32CubeIDE development environment.
Stats One
William FooteThe Rails 7 Way
Obie Fernandez, Lucas Dohmen, and Tom Henrik AadlandThe Rails™ 7 Way is the comprehensive, authoritative reference guide for professionals delivering production-quality code using modern Ruby on Rails. It illuminates the entire Rails 7 API, its most powerful idioms, design approaches, and libraries. Building on the previous editions, this edition has been heavily refactored and updated.
Machine Learning Q and AI
Sebastian Raschka, PhDHave you recently completed a machine learning or deep learning course and wondered what to learn next? With 30 questions and answers on key concepts in machine learning and AI, this book provides bite-sized bits of knowledge for your journey to becoming a machine learning expert.
Gradual Modularization for Ruby and Rails
Stephan HagemannGet yourself a new tool to manage your Rails application and your growing engineering organization! Prevent the ball-of-mud (and fix it!). Go for microservices or SOA if it makes sense not just because you don't have any other tool. Do all this through a low-overhead tool: packages. Enable better conversations to make practical changes today.
Top Bundles
- #1
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... - #2
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
1500 QUIZ COMMENTATI (3 libri)
3 Books
Tre libri dei QUIZ MMG Commentati al prezzo di DUE! I QUIZ dei concorsi ufficiali di Medicina Generale relativi agli anni: 2000-2001-2003-2012-2013-2014-2015-2016-2017-2018-2019-2020-2021 +100 inediti Raccolti in unico bundle per aiutarvi nello studio e nella preparazione al concorso. All'interno di ogni libro i quiz sono stati suddivisi per... - #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!? - #6
Modern C++ Collection
3 Books
Get All about Modern C++C++ Standard Library, including C++20Concurrency with Modern C++, including C++20C++20Each book has about 200 complete code examples. Updates are included. When I update one of the books, you immediately get the updated bundle. You can expect significant updates to each new C++ standard (C++23, C++26, .. ) and also... - #7
Linux Administration Complet
4 Books
Ce lot comprend les quatre volumes du Guide Linux Administration :Linux Administration, Volume 1, Administration fondamentale : Guide pratique de préparation aux examens de certification LPIC 1, Linux Essentials, RHCSA et LFCS. Administration fondamentale. Introduction à Linux. Le Shell. Traitement du texte. Arborescence de fichiers. Sécurité... - #9
Development and Deployment of Multiplayer Online Games, Part ARCH. Architecture (Vol. I-III)
3 Books
What's the Big Idea? The idea behind this book is to summarize the body of knowledge that already exists on multiplayer games but is not available in one single place.And quite a fewof the issues discussed within this series (planned as three nine volumes ~300 pages each), while known in the industry, have not been published at all (except for... - #10
Growing Agile: The Complete Coach's Guide
7 Books
Growing Agile: Coach's Guide Series This bundle provides a collection of training and workshop plans for a variety of agile topics. The series is aimed at agile coaches, trainers and ScrumMasters who often find themselves needing to help teams understand agile concepts. Each book in the series provides the plans, slides, handouts and activity...