Discover millions of ebooks, audiobooks, and so much more with a free trial

Only $9.99/month after trial. Cancel anytime.

Learning SaltStack
Learning SaltStack
Learning SaltStack
Ebook260 pages2 hours

Learning SaltStack

Rating: 4 out of 5 stars

4/5

()

Read preview

About this ebook

About This Book
  • Execute commands and enforce the state of your entire infrastructure in seconds.
  • Make managing your servers as easy as visualizing the end goal -- let SaltStack do the heavy lifting through the state system.
  • Learn by doing in this step by step guide to getting started with SaltStack.
Who This Book Is For

If you are a system administrator who manages multiple servers, then you know how difficult it is to keep your infrastructure in line. If you've been searching for an easier way, this book is for you. No prior experience with SaltStack is required.

LanguageEnglish
Release dateJan 27, 2015
ISBN9781784399016
Learning SaltStack

Related to Learning SaltStack

Related ebooks

Databases For You

View More

Related articles

Reviews for Learning SaltStack

Rating: 4 out of 5 stars
4/5

1 rating0 reviews

What did you think?

Tap to rate

Review must be at least 10 words

    Book preview

    Learning SaltStack - Colton Myers

    Table of Contents

    Learning SaltStack

    Credits

    About the Author

    About the Reviewers

    www.PacktPub.com

    Support files, eBooks, discount offers, and more

    Why subscribe?

    Free access for Packt account holders

    Preface

    What this book covers

    What you need for this book

    Who this book is for

    Conventions

    Reader feedback

    Customer support

    Errata

    Piracy

    Questions

    1. Diving In – Our First Salt Commands

    Introducing Salt

    Installing Salt

    Installation with system packages (Ubuntu)

    Installing with Salt-Bootstrap

    Configuring Salt

    Firewall configuration

    Salt minion configuration

    Starting the Salt master and Salt minion

    Accepting the minion key on the master

    A game of ping pong

    Masterless Salt

    Summary

    2. Controlling Your Minions with Remote Execution

    The structure of a remote execution command

    Command-line options

    Targeting strings

    Glob matching

    Perl-compatible regular expression matching

    List matching

    Grain and pillar matching

    Grains

    Pillars

    Compound matching

    Remote execution modules and functions

    Adding users

    Installing packages

    Managing services

    Monitoring minion states

    Running arbitrary commands

    Summary

    3. Execution Modules – Write Your Own Solution

    Exploring the source

    Cross-calling execution modules

    Grains and the __virtual__ function

    The__opts__ and __pillar__ functions

    Reformatting return data

    An advanced example

    Summary

    4. Defining the State of Your Infrastructure

    Our first state

    The pieces of a state declaration

    Expanding to encompass multiple pieces of state

    Dependencies using requisites

    The require requisite

    The watch requisite

    Other requisites

    The _in requisites

    Summary

    5. Expanding Our States with Jinja2 and Pillar

    Adding a new minion

    Jinja2

    apache2 or httpd?

    Defining secure minion-specific data in pillar

    Using pillar data in states

    Summary

    6. The Highstate and Environments

    The highstate

    Environments

    Environments in pillar

    Expanding our base environment

    Storing our states in Git with GitFS

    Summary

    7. Using Salt Cloud to Manage Virtual Minions

    Setting up Salt Cloud

    Setting up Linode

    Creating an API key

    Creating a cloud provider configuration

    Creating cloud VM profiles

    Create and destroy machines

    Managing groups of VMs with map files

    Creating new masters with map files

    Summary

    8. The Reactor and the Event System

    The Salt event system

    Listening for events

    Event structure

    Firing events from Salt

    Firing events from custom code

    Reacting to events

    Summary

    Index

    Learning SaltStack


    Learning SaltStack

    Copyright © 2015 Packt Publishing

    All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.

    Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.

    Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.

    First published: January 2015

    Production reference: 1210115

    Published by Packt Publishing Ltd.

    Livery Place

    35 Livery Street

    Birmingham B3 2PB, UK.

    ISBN 978-1-78439-460-8

    www.packtpub.com

    Credits

    Author

    Colton Myers

    Reviewers

    Darrel Clute

    Cameron R. Lane

    Hoàng Đình Quân

    Commissioning Editor

    Pramila Balan

    Acquisition Editor

    Kevin Colaco

    Content Development Editor

    Parita Khedekar

    Technical Editor

    Vijin Boricha

    Copy Editors

    Sarang Chari

    Relin Hedly

    Project Coordinator

    Neha Thakur

    Proofreaders

    Simran Bhogal

    Stephen Copestake

    Maria Gould

    Ameesha Green

    Paul Hindle

    Indexer

    Tejal Soni

    Production Coordinator

    Alwin Roy

    Cover Work

    Alwin Roy

    About the Author

    Colton Myers is a software engineer living in Salt Lake City, Utah. Since graduating with a BS in computer science from the University of Utah, he has worked professionally writing software in Python. Colton loves working on open source software, and he has represented the US PyCon conference as a speaker multiple times.

    He is a SaltStack Certified Trainer and has worked on the Salt open source software for years. At the time of writing this book, Colton was working as a platform engineer for SaltStack.

    You can find him on Twitter and GitHub at @basepi.

    I would like to thank my friends and family for the support they've given me while writing this book. I especially want to thank my parents, Mark and Annette, as I would not be who or where I am without their support. Finally, I'd like to thank Thomas Hatch, the creator of SaltStack, who gave me the opportunity to help develop such a great piece of software.

    About the Reviewers

    Darrel Clute is an IT Infrastructure Architect. Throughout his career, he has been predominately focused on network engineering, but has spent equal amounts of time on systems engineering, primarily with UNIX-based systems. Besides his employment, he is also an advocate for open source software used in the enterprise as well as for individuals, but will never advocate the use of open source purely for the sake of it.

    Outside his core competencies, Darrel also has extensive experience with proprietary and open source virtualization platforms. His knowledge and experience in IaaS solutions such as OpenStack are constantly increasing as well. Additionally, through his systems engineering experience, he has been exposed to and supported various web and enterprise applications. The most recent exposure has been to PaaS solutions, and this has led to advocation that either a public or private cloud offering is not complete without a coupling of both Iaas and PaaS solutions designed and deployed in lockstep.

    Besides core infrastructure, he has, at various times, and especially more so recently, been developing programming skills to augment his daily activities. Throughout his career, Darrel has utilized various languages and utilities to automate infrastructure. Some of his programming has been with the use of Bash, Net-SNMP, Sed, and Awk, and holistically with Python.

    Cameron R. Lane is a full-stack engineer with an interest in a broad range of languages and technologies. He is currently a senior software developer at Synapp.io in Atlanta, GA, where he designs and builds scalable APIs for the Web using MongoDB and Python.

    I would like to thank my wife, Stephanie, for her understanding and patience through all of life's changes, big and small. It is her support that gives me the motivation and confidence to take on big challenges. I would also like to thank my colleagues at Synapp.io, who teach me something new about technology every day.

    Hoàng Đình Quân is a Vietnamese System Administrator with experience in operating Network Infrastructure and OpenStack cloud platform automation tools (such as Ansible and SaltStack).

    www.PacktPub.com

    Support files, eBooks, discount offers, and more

    For support files and downloads related to your book, please visit www.PacktPub.com.

    Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at for more details.

    At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks.

    https://www2.packtpub.com/books/subscription/packtlib

    Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can search, access, and read Packt's entire library of books.

    Why subscribe?

    Fully searchable across every book published by Packt

    Copy and paste, print, and bookmark content

    On demand and accessible via a web browser

    Free access for Packt account holders

    If you have an account with Packt at www.PacktPub.com, you can use this to access PacktLib today and view 9 entirely free books. Simply use your login credentials for immediate access.

    Preface

    SaltStack (or Salt, for short) is an open source project that was started by Thomas Hatch in 2011. It was originally intended to be a lightning-fast remote-execution system. Later, the various pieces that make up the Salt that we know today were added on top of this flexible layer. Salt is now one of the most popular open source projects in the world and one of the most popular infrastructure management platforms.

    The project is managed by SaltStack, a company dedicated to preserving the open source nature of the software. SaltStack provides service, long-term support, and custom code in its enterprise product. The company also supports the open source Salt project with a team of dedicated engineers.

    Why do you care? What can Salt do for you?

    Salt is the easiest, most powerful way to manage your servers. Whether you have a few, hundreds, or even tens of thousands of servers, you can use Salt to manage them from a single, central point. You can use it to flexibly target any subset of your servers to run commands or accomplish tasks. You can use the state system to define the state of your infrastructure in a data-driven way and then enforce that state in seconds, with a single command. You can even create a reactive, self-healing infrastructure using the event system. Salt is written in Python and designed to be easy to extend for your own specific use cases or purposes.

    We're going to learn how to do all this and more in these pages. By the end of this book, you will have the knowledge you need to begin making the management of your infrastructure easier with Salt.

    Let's get to it!

    What this book covers

    Chapter 1, Diving In – Our First Salt Commands, teaches you how to install Salt and execute basic commands.

    Chapter 2, Controlling Your Minions with Remote Execution, covers how to use Salt to accomplish tasks on your minions through remote execution.

    Chapter 3, Execution Modules – Write Your Own Solution, teaches you how to write your own custom remote-execution modules to extend Salt for your own purposes.

    Chapter 4, Defining the State of Your Infrastructure, covers how to use Salt states to define and enforce the state of your infrastructure.

    Chapter 5, Expanding Our States with Jinja2 and Pillar, shows how to make your states more flexible and powerful using Jinja2 and pillar data.

    Chapter 6, The Highstate and Environments, teaches you how to structure your states into environments and enforce the state of your entire infrastructure using a single command.

    Chapter 7, Using Salt Cloud to Manage Virtual Minions, covers how to manage your cloud virtual machines using

    Enjoying the preview?
    Page 1 of 1