Snippet
Snippets are reusable configuration templates that can be shared across multiple folders in Strata Cloud Manager. The scm CLI provides commands to create, update, delete, list, bulk import, and back up snippets.
Overview
The snippet commands allow you to:
- Create snippets with optional labels and prefix settings
- Update existing snippet configurations
- Delete snippets that are no longer needed
- Bulk import snippets from YAML files
- Export snippets for backup or migration
Set Snippet
Create or update a snippet.
Syntax
scm set setup snippet NAME [OPTIONS]
Arguments
| Argument | Description | Required |
|---|---|---|
NAME | Snippet name | Yes |
Options
| Option | Description | Required |
|---|---|---|
--description TEXT | Description | No |
--labels TEXT | Labels to apply | No |
--enable-prefix | Enable prefix for the snippet | No |
Examples
Create a Simple Snippet
$ scm set setup snippet "DNS-Best-Practice"
---> 100%
Created snippet: DNS-Best-Practice
Create a Snippet with Description and Labels
$ scm set setup snippet "Web-Security" \
--description "Web security config" \
--labels prod
---> 100%
Created snippet: Web-Security
Create a Snippet with Prefix Enabled
$ scm set setup snippet "Branch-Template" \
--description "Standard branch config" \
--enable-prefix
---> 100%
Created snippet: Branch-Template
Delete Snippet
Delete a snippet from SCM.
Syntax
scm delete setup snippet NAME [OPTIONS]
Arguments
| Argument | Description | Required |
|---|---|---|
NAME | Name of the snippet to delete | Yes |
Options
| Option | Description | Required |
|---|---|---|
--force | Skip confirmation prompt | No |
Example
$ scm delete setup snippet "DNS-Best-Practice" --force
---> 100%
Deleted snippet: DNS-Best-Practice
Load Snippet
Load multiple snippets from a YAML file.
Syntax
scm load setup snippet [OPTIONS]
Options
| Option | Description | Required |
|---|---|---|
--file PATH | YAML file to load configurations from | Yes |
--dry-run | Simulate execution without applying changes | No |
YAML File Format
---
snippets:
- name: DNS-Best-Practice
description: "DNS security best practices"
- name: Web-Security
description: "Web security config"
labels:
- prod
enable_prefix: true
Examples
Load Snippets from File
$ scm load setup snippet --file snippets.yaml
---> 100%
✓ Loaded snippet: DNS-Best-Practice
✓ Loaded snippet: Web-Security
Processed 2 snippets from snippets.yaml
Dry Run
$ scm load setup snippet --file snippets.yaml --dry-run
---> 100%
Dry run mode: would apply the following configurations:
- name: DNS-Best-Practice
description: DNS security best practices
- name: Web-Security
description: Web security config
labels:
- prod
enable_prefix: true
Show Snippet
Display snippet objects.
Syntax
scm show setup snippet [NAME] [OPTIONS]
Arguments
| Argument | Description | Required |
|---|---|---|
NAME | Name of the snippet to show; omit to list all | No |
Options
| Option | Description | Required |
|---|---|---|
--output, -o [table|json|yaml] | Output format (default: table) | No |
--max-results INTEGER | Maximum number of results to display | No |
note
When no NAME is specified, all snippets are listed by default.
Examples
Show Specific Snippet
$ scm show setup snippet "DNS-Best-Practice"
---> 100%
Snippet: DNS-Best-Practice
================================================================================
Description: DNS security best practices
Type: predefined
Labels: prod
Enable Prefix: true
List All Snippets (Default Behavior)
$ scm show setup snippet
---> 100%
Snippets (3):
--------------------------------------------------------------------------------
Name: DNS-Best-Practice
Description: DNS security best practices
Type: predefined
--------------------------------------------------------------------------------
Name: Web-Security
Description: Web security config
Type: custom
--------------------------------------------------------------------------------
Name: Branch-Template
Description: Standard branch config
Type: custom
--------------------------------------------------------------------------------
Backup Snippets
Backup all snippet objects to a YAML file.
Syntax
scm backup setup snippet [OPTIONS]
Options
| Option | Description | Required |
|---|---|---|
--file TEXT | Output filename for backup | No |
Examples
Backup with Default Filename
$ scm backup setup snippet
---> 100%
Successfully backed up 8 snippets to snippets_20240115_120530.yaml
Backup with Custom Filename
$ scm backup setup snippet --file my-snippets.yaml
---> 100%
Successfully backed up 8 snippets to my-snippets.yaml
Best Practices
- Use Descriptive Names: Choose snippet names that clearly indicate the configuration purpose.
- Apply Labels for Organization: Use labels to categorize snippets by function or environment.
- Enable Prefix When Sharing: Use
--enable-prefixwhen snippets are shared across folders to avoid naming conflicts. - Back Up Before Changes: Export your snippets before making significant modifications.
- Use Dry Run for Bulk Imports: Preview bulk imports with
--dry-runbefore applying changes.