Book Image

Learning SaltStack - Second Edition

By : Colton Myers
Book Image

Learning SaltStack - Second Edition

By: Colton Myers

Overview of this book

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. We?ll 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.
Table of Contents (17 chapters)
Learning SaltStack Second Edition
About the Author
About the Reviewer

Masterless Salt

In this chapter, we've taken the time to set up Salt in a master-minion relationship. This will allow us to take advantage of all the power of Salt and scale to multiple minions easily later on. However, Salt is also designed so that a minion can run without a master.

We'll run through a few examples of how to run commands on a minion. This will also be useful even when we do have a master because if we're logged into a minion for some reason and want to run a command while we're there, we can do so using these same concepts.

To start, we'll leave our master running. The command used to run commands on the minion is salt-call, and it can take any of the same execution module functions that we used with the salt command, as follows:

# sudo salt-call

Note that it doesn't display our minion's ID because we're just running it locally:

# sudo salt-call test.fib 10
      - 0
      - 1
      - 1
      - 2
      - 3
      - 5
      - 8
    - 5.00679016113e-06
# sudo salt-call sys.doc

            Used to make sure the minion is up and responding. Not
            an ICMP ping.

            Returns ``True``.

            CLI Example:

                salt '*'

Now, let's stop our master and try again:

# sudo service salt-master stop
# sudo salt-call
Failed sign in

The example shown previously will take a fairly long time to terminate. Basically, salt-call is trying to establish a connection with the master just in case it needs to copy files from the master or other similar operations.

In order for salt-call to operate properly without a master, we need to tell it that there's no master. We do this with the --local flag, as follows:

# sudo salt-call --local

Success! You can now operate a Salt minion without a master!


Start your master again before moving on to the next chapter of this book:

# sudo service salt-master start