Scheduler
Scheduler¶
Tool that allows you to plan different actions on certain Cloud elements.
The columns shown by default in the list are the following:
- Schedule: scheduled time planning.
- Time zone: Time zone of the schedule in which it will be executed.
- Last execution: Last execution of the planning.
-
Error: If there has been an error in its execution, if we have an error it will be highlighted with a striking color for easy visualization.
-
Last synchronization: last synchronization of the schedule.
- Last synchronization error: description of the last failed synchronization error.
The actions that can be executed on each task are listed below
- "View instances" button: allows you to simulate the search for objects based on the search patterns of the task.
- "Show LOGs" button: displays the LOGs corresponding to that task, described below.
- "Show Info" button: displays detailed task information.
- "Run" button: immediately executes that schedule.
- "Edit" button: edit the task.
- "Clone" button: duplicates the task with a random name with the same parameters as this one; Useful to create similar tasks, but with different actions (shutdown, start, etc.).
- "Delete" button: allows you to delete the task, upon confirmation.
When creating or editing a task, we will be shown a form with the following fields:
- Name: a descriptive name is recommended, it is a mandatory field.
- Description: An optional description.
-
Disabled: we can disable scheduling to prevent its execution.
-
Account: Selection of the account in which the task will be executed, all objects added to that task must belong to that account (required).
-
Type of planning: choose between "Fixed rate" and "Cron expression"; note that the cron expression must be specified in UTC format.
- Fixed rate: task execution intervals hour, minutes or days. Detailed information in RateExpressions.
- Cron expression: cron expression, in Linux cron or AWS cron format; Detailed information in CronExpressions.
-
Time zone: allows you to select a time zone to preview the following executions. Keep in mind that this will not be the execution time zone; it is simply an aid to specify the cron expression in UTC format.
We can preview the next 5 executions of the task. Note that if we select a time zone, in the left part of the table we will see the following executions in our selected time zone and in the right part a conversion to the time zone that we have put in our profile to visualize the application.
-
Check Shutdown Policy: If it is checked and the instance does not contain ShutdownPolicy tag, the action indicated in the task will be executed.
-
Selection of objects: depending on the type of action, we can directly select certain objects on which the action will be performed. These fields allow you to specify multiple objects for each field, and as you type, you search dynamically.
-
Search for objects: it is possible to dynamically search for the objects on which the action will be executed based on certain properties, for example, environment, project, etc.
If we select some of the options we can make a more detailed filter of the searches; The fields on which searches can be performed will be displayed:
-
Project: filtered by project name.
- Environment: filtered by environment.
-
Free search: allows you to search by different fields, depending on the type of resource; for example, for AWS EC2 instances you would search by name; You can specify the % character as a wildcard; For example:
MYAPPLICATIONPRE%
-
Action: allows you to select the action to be executed on the specified objects.
-
Backup options: When the selected action is backup, two fields appear that allow you to specify a prefix and a retention period. Both fields are optional.
Tipos de expresiones de Cron¶
SSMCM allows 2 types of cron expressions:
- Standard cron expressions; this type of expression is detected when the expression contains 5 fields. In this case, the expression is validated as a standar Unix cron expression, and translated, when synchronized to AWS Cloudwatch rules, to a AWS cron expression.
- AWS cron expressions; this type is detected when the value contains 6 fields; in this case, the expression is NOT validated when adding/editing the task (as right now there is no library that validates this type of expression). So, this expression is only validated by AWS when synchronizing the task. Please, be careful with this; refer to the documentation for the expression syntax. The only way to see if the expression is valid, is to wait for the task synchronization and see if there has been errors (there is a column in the tasks table indicating if there has been an error during task synchronization).
Setting week days
When setting week days in expression, please remember that:
- Standard cron expression allows values 0-6 (sunday-saturday)
- AWS cron expression allows values 1-7 (sunday-saturday)
Tasks in SSMCM DB are synchronized (created/updated/deleted) every 5 minutes to Cloudwatch rules. You can force the tasks synchronization from the maintenance option.
Remeber to add ShutdownPolicy tag to the instances
The ShutdownPolicy tag must be set in every object:
- AWS EC2
- AWS RDS instances
- Azure VMs
- Google Cloud VMs
Ansible tasks¶
SSMCM allows you to schedule actions based on the execution of Ansible playbook, selecting the option "Job of Ansible" as an action when creating/editing a scheduled task.
When creating/editing an Ansible task we have to specify the following fields:
- Resource Type: On which to run the Ansible task. The available options are:
- Aws EC2 (instances not managed by AWS)
- Azure VM
- Google Cloud Compute Instance
- Oracle Cloud Compute Instance
- Instances: On which the Ansible task will run. You can select instances corresponding to the account and resource type defined for the task. For tasks on AWS EC2 instances, only instances that are not managed by AWS can be specified.
To select instances, you can search filtered by id (external generated by the resource provider) and instance name
- Playbook: Ansible template that will run the task. You can choose between different templates based on the type of resource on which the task will be executed.
- Ansible playbook extra variables (optional): The variables passed to the Ansible playbook for execution. For required variables, once the playbook is selected, a template will be displayed with the description of these required variables.
Scheduler LOGs¶
Viewing LOGs
The LOGs allow to visualize a record of the actions carried out on the resources, in the different tasks. Each row is displayed in a different color, depending on the type of message. This table, like the rest, is filterable and sortable.
- Error: red
- Notice: orange
- Correct: green
An example of visualization would be: