Book Image

Salt Cookbook

By : Anirban Saha
Book Image

Salt Cookbook

By: Anirban Saha

Overview of this book

Table of Contents (18 chapters)
Salt Cookbook
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface
Index

Preface

Salt is one of the many but unique tools available today for configuration management and orchestration. Salt not only enables us to seamlessly configure our infrastructure, but also to perform all sorts of tasks based on a variety of conditions and properties of the Salt minions. Along with super-fast module execution with the help of the ZeroMQ messaging library, Salt takes orchestration to a whole new level, which can be used for numerous day-to-day tasks starting from simple data collection to complex deployments.

This book provides a hands-on approach to the world of Salt. It provides a basic understanding of the concepts and architecture on which Salt is based, and then moves on to details about configuring it and also writing complex recipes for different tasks and scenarios.

The content of the book definitely helps professionals associated with infrastructure management to consider Salt as a potential tool for implementing their infrastructure and it also provides lot of recipes which existing Salt users can refer to. With the help of the content of the book, users can also integrate Salt with other tools and services to get the optimal results required.

The book starts off with the concepts and architecture of Salt, followed by some basic and advanced configurations and module usages. The next topics are about configuring application and database servers, cloud-based services, and event systems. It finishes off with recipes for troubleshooting Salt.

What this book covers

Chapter 1, Salt Architecture and Components, gives you a basic understanding about the concept and architecture of Salt. It explains a lot of Salt terminology, such as the Salt master, minions, states, pillars, environments, and grains, and demonstrates how to configure them.

Chapter 2, Writing Advanced Salt Configurations, goes a bit deeper into Salt configuration and gives you a detailed explanation of the various data manipulation you can perform in Salt, such as conditionals, iterations, and Python functions. It also focuses on the very important topic of targeting minions using different techniques.

Chapter 3, Modules, Orchestration, and Scaling Salt, gives you an even deeper understanding of the advanced Salt concepts of execution and state modules, using templates, requisites, and Salt runners, performing orchestration and demonstrates multi-master setups for redundancy.

Chapter 4, General Administration Tasks, provides hands-on recipes on configuring general system entities, such as users, groups, SSH configurations, scheduling with cron, volume, and disk management with network configuration. It also explains how to add custom grains to a minion.

Chapter 5, Advanced Administration Tasks, provides explanations and demonstrations about advanced system topics such as package repository configuration and package management, file and service management, managing code repositories and handling alternatives.

Chapter 6, Managing Application Servers, gives an understanding of how to configure web and application servers by handling each configuration step-by-step in the recipes. It demonstrates package and service configuration, manages the server configuration file, and deployments for application servers and security for web servers.

Chapter 7, Managing Databases, provides detailed explanations and demonstrations of database configuration for MySQL and PostgreSQL. It includes database package and service management, managing users and groups, databases, grants and queries.

Chapter 8, Configuring Salt Cloud, provides extensive knowledge about how to manage cloud infrastructures using Salt Cloud. It demonstrates the usage of Salt Cloud, providers and profiles, cloud maps, post-install scripts, and management of cloud resources such as instances and volumes using Salt Cloud.

Chapter 9, Managing Amazon Web Services, focuses specifically on how to manage the EC2 Cloud hosted by Amazon Web Services. It includes recipes to manage security groups, load balancers, DNS with Route53, Simple Queue Service, ElastiCache clusters and CloudWatch alarms.

Chapter 10, Salt Event and Reactor System, explains and demonstrates the event system of Salt and how to request and receive events using the Salt message bus. It also explains how to use the event system to configure the reactor system in Salt to perform required tasks.

Chapter 11, Troubleshooting, demonstrates several scenarios where things can go wrong with the Salt system and how you can troubleshoot and fix such problems.

What you need for this book

RedHat/CentOS/Scientific Linux, as Salt does not have support for Windows. However, the minion can be installed on a variety of systems including Solaris and Windows. The Salt system is based on Python and depends on a few Python libraries, which get automatically resolved and installed when a package manager is used to install the packages. If not automatically resolved, these dependencies need to be installed first.

Although a single system can be used to configure the master and minion, a network containing a few different systems is needed to configure and demonstrate Salt optimally by configuring a master and multiple minions, or each minion can be their own master as explained in the book.

Also, a working Internet connection is required to fetch packages for configuration.

Who this book is for

If you are a professional associated with system and infrastructure management, looking at automated infrastructure and deployments, then this book is for you. No prior experience of Salt is required.

Sections

In this book, you will find several headings that appear frequently (Getting ready, How to do it, How it works, There's more, and See also).

To give clear instructions on how to complete a recipe, we use these sections as follows:

Getting ready

This section tells you what to expect in the recipe, and describes how to set up any software or any preliminary settings required for the recipe.

How to do it…

This section contains the steps required to follow the recipe.

How it works…

This section usually consists of a detailed explanation of what happened in the previous section.

There's more…

This section consists of additional information about the recipe in order to make the reader more knowledgeable about the recipe.

See also

This section provides helpful links to other useful information for the recipe.

Conventions

In this book, you will find a number of text styles that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning.

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "The sudo command needs to be added before the mentioned commands."

A block of code is set as follows:

file_roots:
  base:
    - /opt/salt-cookbook/base
  production:
    - /opt/salt-cookbook/production
  staging:
    - /opt/salt-cookbook/staging
  development:
    - /opt/salt-cookbook/development

Any command-line input or output is written as follows:

[root@salt-master ~]# service salt-master restart

New terms and important words are shown in bold, like this: "Salt is a systems management software created and maintained by SaltStack."

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of.

To send us general feedback, simply e-mail , and mention the book's title in the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files from your account at http://www.packtpub.com for all the Packt Publishing books you have purchased. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title.

To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.

Piracy

Piracy of copyrighted material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors and our ability to bring you valuable content.

Questions

If you have a problem with any aspect of this book, you can contact us at , and we will do our best to address the problem.