Book Image

Learning SaltStack

By : Colton Myers
Book Image

Learning SaltStack

By: Colton Myers

Overview of this book

Table of Contents (15 chapters)

Exploring the source


By design, Salt makes it very easy to write your own custom execution modules and functions. It abstracts away much of the nitty-gritty about writing Python for system administration, yet leaves you with all the power of Python to get things done.

This means that we can write Salt modules that integrate with our own internal tools or proprietary software. We can even write quick modules just to reorganize or reformat data for use in other parts of Salt.

There will be more on that later. For now, let's inspect our first remote execution function in Salt, which is as follows:

def sleep(length):
    '''
    Instruct the minion to initiate a process that will sleep
    for a given period of time.

    CLI Example:

    .. code-block:: bash

        salt '*' test.sleep 20
    '''
    time.sleep(int(length))
    return True

This is the code for test.sleep, a function that we ran in the previous chapter. (Remember that execution modules take the form <module>.<function...