Salt Essentials
by Craig Sebenik and Thomas Hatch
Copyright 2015 Craig Sebenik and Thomas Hatch. All rights reserved.
Printed in the United States of America.
Published by OReilly Media, Inc. , 1005 Gravenstein Highway North, Sebastopol, CA 95472.
OReilly books may be purchased for educational, business, or sales promotional use. Online editions are also available for most titles (http://safaribooksonline.com). For more information, contact our corporate/institutional sales department: 800-998-9938 or corporate@oreilly.com .
- Editors: Courtney Nash and Brian Anderson
- Production Editor: Matthew Hacker
- Copyeditor: Rachel Monaghan
- Proofreader: Sonia Saruba
- Indexer: Judith McConville
- Interior Designer: David Futato
- Cover Designer: Ellie Volckhausen
- Illustrator: Rebecca Demarest
Revision History for the First Edition
- 2015-06-05: First Release
See http://oreilly.com/catalog/errata.csp?isbn=9781491900635 for release details.
The OReilly logo is a registered trademark of OReilly Media, Inc. Salt Essentials, the cover image of a conger eel, and related trade dress are trademarks of OReilly Media, Inc.
While the publisher and the authors have used good faith efforts to ensure that the information and instructions contained in this work are accurate, the publisher and the authors disclaim all responsibility for errors or omissions, including without limitation responsibility for damages resulting from the use of or reliance on this work. Use of the information and instructions contained in this work is at your own risk. If any code samples or other technology this work contains or describes is subject to open source licenses or the intellectual property rights of others, it is your responsibility to ensure that your use thereof complies with such licenses and/or rights.
978-1-491-90063-5
[LSI]
Preface
Who Should Read This Book
Do you want to automate your infrastructure?What about managing your configuration files?Do you use Python?Salt provides a system to manage simple and complex infrastructures.This book will give you an introduction if you have never used Salt, touching on the major pieces and giving you enough information tofeel comfortable in deploying Salt in a major production infrastructure.
Whether you are a sysadmin responsible for the installation and maintenanceof the operating system or you are a devops engineer at a startupresponsible for getting your code to hundred of systems, Saltis a tool to make your job easier.Salt is used by small and large companies to manage tasks ranging from maintaining the basicoperating system parameters and configuration all the way todeploying and configuring custom applications.
Many of the examples in this book assume that you have some basic familiarity withPython and YAML.But knowledge of these technologies is not an absolute requirement.If you have some programming experience and some experience withbasic data formats (e.g., JSON or XML),then you should be able to follow along without much trouble.At an even more basic level, you should have some working knowledge ofLinux and a basic filesystem layout.
Salt can help you solve a wide variety of problems.One of its best features is that, as with Python, much of Salts internalsare exposed to you.This book only gives a glimpse into the possibilities of working with Salt, but it will provide you with a basic understanding from which you can dive intomore of the details independently.
Why We Wrote This Book
When I (Craig) first started learning Salt, I was overwhelmed by its features,terms, and even some of the concepts.The more I worked with it and the more I learned,the more I wanted to use Salt to solve even more problems.As Salt spread in my company, I saw my coworkers struggle the same way I did.The documentation on the SaltStack website is great, but it wasnt sufficient.I wrote this book because I wanted others to be able to jump right inwith a solid understanding of the basics.
What This Book Is Not
Salt is a great tool for solving a large and various set of problems.Salt grows more and more every day.Mew features are added, existing features are improved,and unnecessary or outdated code is removed.I wanted to give a firm base from which you could learn more and moreabout Salt.But, covering everything Salt can do is well beyond the scope of a single book.Our goal is to cover the basics, the essentials of Salt.This book will give you a solid platform to build upon.The topics in this book are generally considered to be the most heavily usedfeatures of Salt.But the coverage is far from complete.This is a great place to start, but not the only place to learn about Salt.
Once you have the basics down,the documentation on the SaltStack website is a great place to learnmore,including details on plenty of advanced features that are,unfortunately,beyond the scope of this book.
A Word on Salt Today
Salt has a very large and heavily engaged user base.It is one of the most contributed projects on GitHub.SaltStack is the company behind Salt.It offers services and training for Salt itself, and is fully committed to Salt being open core.There is an active mailing list, a very chatty IRC channel,and plenty of discussions and pull requests on GitHub.As of this writing, version 2015.2.0 (codenamed Lithium) was released.
Navigating This Book
This book is organized roughly as follows:
introduces the basic organization of Salt.
gives a quick summary of the basic command-line utilities.
Chapters introduce you to two of the fundamental pieces of Salt:the remote execution engine and the state system.
guides you through the basic data elements at the core of Salt.
Chapters describe how you can extend and customize Salt.
Chapters give more information on the main control point(the Salt master) and some various ways you can structure Salt.
The final chapter, , gives a very simple introduction tousing Salt in a cloud infrastructure.
If you have used Salt even a little,you can likely skip Chapters
Online Resources
The Salt documentation is very thorough and a fantastic reference. The documentation pages will link to all of the resources you needto learn even more about Salt and the various technologiesused.
Conventions Used in This Book
The following typographical conventions are used in this book:
ItalicIndicates new terms, URLs, email addresses, filenames, and file extensions.
Constant width
Used for program listings, as well as within paragraphs to refer to program elements such as variable or function names, databases, data types, environment variables, statements, and keywords.
Constant width bold
Shows commands or other text that should be typed literally by the user.
Constant width italic
Shows text that should be replaced with user-supplied values or by values determined by context.
Tip
This icon signifies a tip or suggestion.
Note
This element signifies a general note.
Warning
This icon indicates a warning or caution.
Using Code Examples
Supplemental material (code examples, exercises, etc.)is available for download athttps://github.com/craig5/salt-essentials-utils.
This book is here to help you get your job done. In general, if example code is offered with this book, you may use it in your programs and documentation. You do not need to contact us for permission unless youre reproducing a significant portion of the code. For example, writing a program that uses several chunks of code from this book does not require permission. Selling or distributing a CD-ROM of examples from OReilly books does require permission. Answering a question by citing this book and quoting example code does not require permission. Incorporating a significant amount of example code from this book into your products documentation does require permission.