Book Image

Salt Cookbook

By : Anirban Saha
Book Image

Salt Cookbook

By: Anirban Saha

Overview of this book

If you are a professional associated with system and infrastructure management, looking at automated infrastructure and deployments, then this book is for you. No prior experience of Salt is required.
Table of Contents (13 chapters)
12
Index

Using execution modules


Modules are the basic foundations of configuration management in Salt. Using Salt modules, we can configure systems from Salt state files, as well as from the command line. In this chapter, you will learn about how to use Salt modules from the command line.

How to do it...

Configure a minion in the staging environment. We will call it stgdc1log01.

  1. Run the following command to list all the cron entries for the root user on the minion:

    [root@salt-master  ~]# salt 'stgdc1log01' cron.list_tab root
    stgdc1log01:
        ----------
        crons:
        env:
        pre:
        special:
    
  2. Run the following command to add a new cron entry for the root user:

    [root@salt-master  ~]# salt 'stgdc1log01' cron.set_job root '00' '12' '*' \ '*' '*' 'find /var/log/ -mtime +30 -exec rm - rf {} \;'
    stgdc1log01:
        new
    
  3. Run the following command to verify that the new cron was added properly:

    [root@salt-master  ~]# salt 'stgdc1log01' cron.list_tab root
    stgdc1log01:
        ----------
        crons:
            |_
        ...