Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Learning SaltStack

You're reading from   Learning SaltStack Build, manage, and secure your infrastructure with the power of SaltStack

Arrow left icon
Product type Paperback
Published in Jun 2016
Publisher Packt
ISBN-13 9781785881909
Length 202 pages
Edition 2nd Edition
Concepts
Arrow right icon
Author (1):
Arrow left icon
Colton Myers Colton Myers
Author Profile Icon Colton Myers
Colton Myers
Arrow right icon
View More author details
Toc

An advanced example

Remote execution modules are endlessly flexible. The tools are there, and you can write whatever you need to extend Salt to handle your infrastructure.

However, we're not going to try to explore every possible need your infrastructure might have, as that is impossible to do in the space allotted. Every environment is different, and we have explored the available tools well enough for you to be able to tackle those hurdles on your own.

Instead, we will explore a more complicated example of a remote execution module function from beginning to end and walk through the code.

The example that we will use is file.replace. This remote execution function is designed to replace text in a file based on a pattern. We can set arguments so that if a match is not found, it will prepend or append the text to the file. Here's a full list of arguments in the function declaration:

def replace(path,
            pattern,
            repl,
            count=0,
            flags=0,...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime