You are previewing Learning SaltStack - Second Edition.
O'Reilly logo
Learning SaltStack - Second Edition

Book Description

Build, manage, and secure your infrastructure by utilizing the power of SaltStack

About This Book

  • First book in the market to incorporate all the latest features of SaltStack.

  • Leverage the power of SaltStack for building, managing and securing your infrastructure.

  • Effectively use commands and control the state of your infrastructure in a jiffy.

  • Who This Book Is For

    This book is aimed at System Administrators who are looking forward to manage their infrastructure using SaltStack with no prior knowledge about it.

    What You Will Learn

  • Install Salt on your servers

  • Run commands on all or some of your minions instantly from a central managing server

  • Write custom Salt modules to handle your infrastructure’s unique needs

  • Define the state of your infrastructure and use Salt to enforce that state.

  • Create platform-agnostic state definitions for greater flexibility and power

  • Manage virtual servers on public or private clouds using Salt Cloud

  • Use the event system in Salt to create a reactive and self-healing infrastructure

  • In Detail

    SaltStack is one of the best infrastructure management platforms available. It provides powerful tools for defining and enforcing the state of your infrastructure in a clear, concise way. With this book learn how to use these tools for your own infrastructure by understanding the core pieces of Salt.

    In this book we will take you from the initial installation of Salt, through running their first commands, and then talk about extending Salt for individual use cases. From there you will explore the state system inside of Salt, learning to define the desired state of our infrastructure in such a way that Salt can enforce that state with a single command. Finally, you will learn about some of the additional tools that salt provides, including salt-cloud, the reactor, and the event system. Well finish by exploring how to get involved with salt and what's new in the salt community.

    Finally, by the end of the book, you'll be able to build a reliable, scalable, secure, high-performance infrastructure and fully utilize the power of cloud computing.

    Style and approach

    This will be a comprehensive guide on SaltStack along with installation and setting up of Salt on couple of platforms. Then enlightening the readers about remote execution system and configuration management system and ending with concepts of security and best practices.

    Downloading the example code for this book. You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the code file.

    Table of Contents

    1. Learning SaltStack Second Edition
      1. Table of Contents
      2. Learning SaltStack Second Edition
      3. Credits
      4. About the Author
      5. About the Reviewer
      6. www.PacktPub.com
        1. eBooks, discount offers, and more
          1. Why subscribe?
      7. Preface
        1. What this book covers
        2. What you need for this book
        3. Who this book is for
        4. Conventions
        5. Reader feedback
        6. Customer support
          1. Downloading the example code
          2. Errata
          3. Piracy
          4. Questions
      8. 1. Diving In – Our First Salt Commands
        1. Introducing Salt
        2. Installing Salt
          1. Installation with system packages (Ubuntu)
          2. Installation with system packages (CentOS 6)
          3. Installation with system packages (Windows)
          4. Installing with Salt Bootstrap
        3. Configuring Salt
          1. Firewall configuration
          2. Salt minion configuration
          3. Starting the Salt master and Salt minion
          4. Accepting the minion key on the master
        4. A game of ping pong
        5. Masterless Salt
        6. Summary
      9. 2. Controlling Your Minions with Remote Execution
        1. The structure of a remote execution command
          1. Command-line options
          2. Targeting strings
            1. Glob matching
            2. Perl-compatible regular expression matching
            3. List matching
            4. Grain and pillar matching
              1. Using grains
              2. Using pillars
            5. Compound matching
          3. Remote execution modules and functions
            1. Adding users
            2. Installing packages
            3. Managing services
            4. Monitoring minion states
            5. Running arbitrary commands
        2. Summary
      10. 3. Execution Modules – Write Your Own Solution
        1. Exploring the source
          1. Cross-calling execution modules
          2. Grains and the __virtual__ function
          3. The__opts__ and __pillar__ functions
          4. Reformatting return data
        2. An advanced example
        3. Summary
      11. 4. Defining the State of Your Infrastructure
        1. Our first state
        2. The pieces of a state declaration
        3. Expanding to encompass multiple pieces of state
        4. Dependencies using requisites
          1. The require requisite
          2. The watch requisite
          3. Other requisites
          4. The _in requisites
        5. Summary
      12. 5. Expanding Our States with Jinja2 and Pillar
        1. Adding a new minion
        2. Jinja2
          1. apache2 or httpd?
        3. Defining secure minion-specific data in pillar
          1. Using pillar data in states
        4. Summary
      13. 6. The Highstate and Environments
        1. The highstate
          1. Environments
            1. Environments in pillar
          2. Expanding our base environment
        2. Storing our states in Git with GitFS
        3. Summary
      14. 7. Using Salt Cloud to Manage Virtual Minions
        1. Setting up Salt Cloud
          1. Setting up Linode
            1. Creating an API key
          2. Creating a cloud provider configuration
          3. Creating cloud VM profiles
          4. Creating and destroying machines
        2. Managing groups of VMs with map files
          1. Creating new masters with the map files
        3. Summary
      15. 8. The Reactor and the Event System
        1. The Salt event system
          1. Listening for events
            1. Event structure
          2. Firing events from Salt
          3. Firing events from custom code
        2. Reacting to events
        3. Summary
      16. 9. Security Best Practices in Salt
        1. Securing Salt configuration
          1. Master configuration
            1. open_mode and auto_accept
            2. file_recv
            3. Peer publishing
          2. Minion configuration
            1. master_finger
        2. Key management
          1. Preseeding the minion keys
          2. Preseeding the master key
          3. Verifying with key fingerprints
            1. Master fingerprint
            2. Minion fingerprints
        3. Firewall and network configuration
        4. Summary
      17. 10. How Can I Get Involved?
        1. Contributing code using GitHub
          1. Creating an account on GitHub
          2. The project
          3. Getting the code
          4. Contributing a fix
          5. Committing our changes
          6. Pushing the changes and creating a pull request
        2. Other ways to get involved
          1. Salt-users mailing list
          2. #salt on freenode IRC
          3. #saltstack on the hangops Slack
        3. Summary
      18. Index