- SaltStack - Working Example
- SaltStack - Python API
- SaltStack - Salt Package Manager
- SaltStack - Orchestration
- SaltStack - Event system
- SaltStack - Salt Proxy Minions
- Salt for Cloud Infrastructure
- SaltStack - Salt through SSH
- SaltStack - Logging
- Configuration Management
- SaltStack - Remote Execution
- SaltStack - Using Cron with Salt
- Using MinionFS as the File Server
- SaltStack - Git as a File Server
- SaltStack - Salt File Server
- SaltStack - Job Management
- SaltStack - Access Control System
- Creating a Simple Environment
- SaltStack - Installation
- SaltStack - Competitors
- SaltStack - Architecture
- SaltStack - Overview
- SaltStack - Home
SaltStack Useful Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
SaltStack - Using Cron with Salt
Salt can be used along with the Cron apppcation. Using both apppcations together provides a great opportunity to automate Salt. While Salt provides an option to execute commands remotely, Cron enables it to run in a pre-scheduled or automated manner. Let us learn how to use Cron and Salt together in this chapter.
What is Cron?
Cron is very useful apppcation in the Linux Environment. It enables to preset a command or script to run in a specific date and time. It also enables to run an apppcation in a regular interval, say daily, weekly or every first day of the month.
Cron starts when the system starts and check the /etc/crontab file for configuration details. The /etc/crontab has every apppcation and its schedule in a separate pne as shown below.
15 * * * * root echo "This command runs at 15 minutes past every hour" 15 10 * * * root echo "This command is run daily at 10:15 am"
Every pne has the following seven entry points, which are separated by space and they are as follows −
minute − minute of the hour and is between ‘0’ and ‘59’.
hour − hour and is specified in the 24-hour clock.
day_of_month − Day of the Month and is between 1 and 31. For example, the 10th of each month is 10.
month − A month specified and is specified numerically (0-12), or as the name of the month (e.g. May).
day_of_week − Day of the week is specified numerically (0-7) or as the name of the day (e.g. Sun).
user − User account under which the command runs.
cmd − The actual command and its arguments.
Here, * replaces, if nothing is assigned.
Salt Caller (salt-call)
Salt provides a CLI (Command Line Interface), salt-call to run the modules in the local minion system itself instead of from the master server using the salt command. The salt call CLI supports all the options supported by salt command, but run locally.
Salt Caller was initially designed to support debugging, but now, it can be used as a standalone apppcation.
salt-call test.ping
Using salt-call in cron
The salt-call CLI is useful to schedule salt operation using Cron. For example, to check the state of the minion every day at midnight, we can use salt-call along with the option – state.apply as shown below.
/etc/crontab
PATH = /bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/opt/bin 0 0 * * * salt-call state.apply
Here,
The state.apply function will check the salt configuration file for the minion and check whether all action defined for the minion is properly configured.
Setting the path is a good practice because sometimes the salt command may not be available in the system path.
In the next chapter, we will learn Remote Execution, which is a core concept of Salt.
Advertisements