Snippets are a predefined set of tasks that can be easily imported into runbooks — with snippets, you can easily create quick fixes for unexpected problems that arise in your runbook. In other instances, you may be simply looking to supplement your original set of tasks with additional snippets depending on your needs. This article will cover snippet functionality, how to create snippets, and the snippet task type.
The snippets you create and their purpose depends on your needs and the overall goal of your runbooks.
This flexibility allows you to create customized solutions for a wide variety of uses and create opportunities for improvement to ensure your runbook executes as planned. You may also think of snippets as a way of creating a library of short processes and actions that can be added to tasks based on any unexpected situation.
For example, in the event a test fails within a runbook, snippets can be used to deploy and execute a fix for the failed test.
Create a snippet
Snippets are created on the workspace level and can be managed within a workspace and any runbook the snippet is in.
To create a snippet, click the Snippets tab in your workspace. Next, click the + Create Snippet button on the upper right-hand corner of the screen.
Next, title your snippet and click + Create.
Once your snippet has been created, you can add up to 100 tasks. When adding tasks, you can title your tasks, select a task type, add a description, and more. Adding details for snippets follows the same process for creating tasks. Read more details about tasks.
Your snippet will need to be approved in order for it to become available for use in your runbook. To approve your snippet, click the Snippet Details icon in the upper right-hand corner of the screen:
Next, click Approval Settings > Approved. Optionally in some cases, you can mark the snippet as Rejected or leave it in draft mode. Snippets that are marked as draft or rejected will not be available for use in a runbook.
Once the snippet has been created and approved by the workspace runbook creator, runbook admins are able to add the approved snippet to any number of runbooks.
Any changes that need to be made to your snippet title or status can be made in the Snippet Details menu. Additionally, once snippets have been imported into a runbook, you are able to edit the tasks from the snippet as you would any other task in a runbook.
Create a snippet from multiple selected tasks
Runbook admins have the ability to create new snippets by selecting up to 100 tasks in an existing runbook. This means that multiple tasks can be selected at any time and added as a snippet.
To create a snippet from multiple selected tasks, navigate to the runbook of your choice and follow the steps below:
Select tasks (up to 100) that you would like to include in your snippet.
Click the Create as Snippet icon.
Enter a title for your snippet.
Once your snippet has been created successfully, a green success message will appear to confirm.
Use a snippet task type
Provided you are a Runbook Admin and your runbook is dynamic, you can use a snippet task type to prompt a task executor to add a snippet at a certain point during a run.
To set up a snippet task type, create your task, click on it to edit it, and select Snippet from the Task Type list.
Click Snippet in the Task Type drop-down menu. You will be prompted to start typing to find the snippet or snippets you’d like to attach to your task. If no snippets are attached, then all of your workspace's approved snippets will be displayed for selection in the task as a default.
Next, click Save at the top of the task editing panel.
When the executor starts the task, the Start task modal will ask them to select a snippet and to click Continue. Alternatively, they can proceed without making any selection at all.
The selected snippet's tasks will be added to the runbook for execution.
Import snippets into a runbook
To import your snippet to a runbook, simply click the More options icon on the task you want your snippet to be the successor of:
Click Add a Snippet.
In the Choose a Snippet modal, select a snippet to add to your runbook:
Next, choose whether the snippet will be added in sequence or in parallel to the other tasks in the runbook. Then, click + Add.
When adding a snippet in sequence, snippet tasks are added between the original task and its successor. When snippets are added in parallel, the snippet tasks are added in parallel (or next to) the original task's successor.
In the below example, task #4 from snippet one is added in sequence after task #1.
In the next image, tasks #5-10 from snippet two are added in parallel after task #2 — notice tasks #5-10 are "next to" task #3.