Scheduled Automation with Morpheus

By: Morpheus Data

Managing IT systems like managing most things in life requires us to repeat certain tasks over and over again often at a certain interval. This is especially important as IT environments span clouds and include hundreds or thousands of systems. The execution of scheduled automation frees up IT personnel to focus high level tasks instead of babysitting a daily repeatable operation. Morpheus enables administrators to schedule Morpheus tasks and workflows to run on a defined schedule. In this blog post we’ll walk through scheduling automation in the Morpheus the platform. We’ll look at scheduling a Python script that runs daily to cleanup old AMIs (Amazon Machine Images) in an AWS account.


The Morpheus platform supports the execution of automation using Bash, PowerShell, Python, Ansible playbooks and other automation tools. In this case we’re creating a Python task to run a Python script that handles AMI cleanup in our AWS account. The following script is an example that fetches the AMIs in the AWS us-east-1 region and removes it if it was created more than 30 days ago.

import boto3
from tabulate import tabulate
import datetime
import time
from morpheuscypher import Cypher

# Expiration days
expiration_days = 30
timeLimit = - datetime.timedelta(days=expiration_days)
data = []

# Fetch AWS account credentials from Cypher

ec2 = boto3.resource('ec2', region_name='us-east-1',
client = boto3.client('ec2', region_name='us-east-1',
response = client.describe_images(Owners=['self'])

# Iterate over the AMIs
for ami in response['Images']:
row = []

# Convert the AMI creation date to a date format to compare with the current date
creation_date_object = datetime.datetime.strptime(creation_date, '%Y-%m-%d').date()
if creation_date_object <


# Print the formatted table
print(tabulate(data, headers=["Name", "ID", "CreationDate", "Expired"]))

Now that we’ve got our python code we’re ready to create our Python task that will run on a daily schedule. We’ve included the boto3, tabulate and morpheus-cypher python libraries as additional packages.

Task creation modal

We need to create two secrets in Morpheus Cypher to securely the AWS credentials used in the python script.

Morpheus cypher

Execution Schedule

Execution schedules in Morpheus provide a generic method for defining when something should be executed. Now that we have our task created we’ll create an execution schedule to define when we want our task to run. We can add the task by going to the Execute Scheduling section of the UI under Provisioning > Automation. Click Add to open the Create Execution Schedule modal to create a new execution schedule. We’ll provide a name and description for our schedule. Select your timezone, in this case the task should run at 7 AM every day Central Standard Time.

Execution schedule modal


Jobs in Morpheus tie together an execution schedule with one of the three Morpheus job types detailed below.

Task Job: Scheduling of Morpheus tasks such as Ansible playbooks or bash scripts.

Workflow Job: Scheduling of Morpheus workflows that stitch together Morpheus tasks.

Security Scan Job: Scheduling of Open SCAP scans on workloads.

In our example we’ll use the task job type to schedule our previously created task.

Scheduled automation summary modal

Select the AWS AMI Cleanup task and the Daily AMI Cleanup execution schedule. The context type is None since we want the script to execute on the Morpheus node.

Scheduled automation configuration modal

Review the job configuration and click COMPLETE to create the job.

Scheduled automation review modal

Now that we’ve scheduled our automation we can view the job details such as the last run and next run. We can also trigger the execution of the job before the scheduled execution.

Scheduled automation job details

Try Morpheus Community Edition or Get a Demo
The Morpheus Community Edition lets you fully experience the Morpheus platform including nearly all features and capabilities! Register at Morpheus Hub and try it in your home lab or test environment today! Interested in learning more about Morpheus from one of our cloud transformation experts? Schedule a demo to walk through how Morpheus can help your organization here.

Related Resources

  • listing image
    May 2024 | Product
    Lab Guide: SuiteCRM Automation with Morpheus
  • card listing image
    May 2024 | Video Demo
    Morpheus Minute: Custom Email Templates 7.0
  • card listing image
    May 2024 | Video Demo
    Morpheus Minute: Console
  • card listing image
    May 2024 | Video Demo
    Morpheus Minute: Load Balancers
  • card listing image
    May 2024 | Video Demo
    Morpheus Minute: Clusters
  • listing image
    May 2024 | Solution
    Morpheus + Dell Solution Brief
  • listing image
    Apr 2024 | Solution
    Morpheus Orchestration for Edge Computing
  • card listing image
    Apr 2024 | Webinar
    Tech Brief: What’s New in Morpheus 7.0
  • listing image
    Apr 2024 | Product
    Morpheus Token Catalog
  • card listing image
    Mar 2024 | Video Demo
    Morpheus Minute: Using AWS Host IAM Credentials in Morp...