Local Storage
Store deployment scripts on the local filesystem.
Overview
Section titled βOverviewβLocal storage provides direct access to scripts stored on the Mantis serverβs filesystem:
When to Use Local Storage
Section titled βWhen to Use Local Storageβ| Use Case | Recommendation |
|---|---|
| Development | Ideal for quick iteration |
| Single server | Works well without external dependencies |
| Air-gapped | Only option without network storage |
| Testing | Fast access for test scripts |
| Migration | Temporary storage during system migration |
Configuration
Section titled βConfigurationβProperties
Section titled βPropertiesβ| Property | Required | Description |
|---|---|---|
| Name | Yes | Unique identifier for the storage |
| Path | Yes | Absolute path to scripts directory |
Creating Local Storage
Section titled βCreating Local StorageβVia Lens UI
Section titled βVia Lens UIβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ Create Local Storage ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€β ββ Name * ββ [scripts ] ββ ββ Path * ββ [/var/mantis/scripts ] ββ ββ βββββββββββββββββββββββββββββββββββββββββββββββββββββββββ ββ β Path must be an absolute path accessible by the β ββ β Mantis server process. β ββ βββββββββββββββββββββββββββββββββββββββββββββββββββββββββ ββ ββ [Cancel] [Create] ββ ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ- Navigate to Storage in the sidebar (under Infrastructure)
- Click New Storage
- Click the Local Storage tab
- Enter a unique name
- Enter the absolute path
- Click Create
Via REST API
Section titled βVia REST APIβ# Create local storagecurl -X POST "$MANTIS_URL/api/v1/storage/local" \ -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \ -d '{"name": "scripts", "path": "/var/mantis/scripts"}'
# Create with a different base pathcurl -X POST "$MANTIS_URL/api/v1/storage/local" \ -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \ -d '{"name": "dev-scripts", "path": "/home/deploy/scripts"}'Directory Structure
Section titled βDirectory StructureβRecommended Layout
Section titled βRecommended LayoutβOrganize scripts within the storage directory:
/var/mantis/scripts/βββ deploy/β βββ web-app.shβ βββ api-service.shβ βββ database.shβββ configure/β βββ nginx.shβ βββ ssl-certs.shβ βββ firewall.shβββ health/β βββ check-web.shβ βββ check-database.shβββ rollback/ βββ restore-backup.shReferencing Scripts
Section titled βReferencing ScriptsβWhen creating actions, reference scripts relative to the storage path:
| Storage Path | Filename | Full Path |
|---|---|---|
/var/mantis/scripts | deploy/web-app.sh | /var/mantis/scripts/deploy/web-app.sh |
/var/mantis/scripts | configure/nginx.sh | /var/mantis/scripts/configure/nginx.sh |
Detail View
Section titled βDetail Viewβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ Local Storage: scripts ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€β ββ Type: Local ββ Path: /var/mantis/scripts ββ Created: January 15, 2024 ββ ββ βββββββββββββββββββββββββββββββββββββββββββββββββββββββββ ββ ββ Used By (3 actions): ββ ββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββ ββ β Action β Filename β ββ ββββββββββββββββββββΌβββββββββββββββββββββββββββββββββββ€ ββ β deploy-web β deploy/web-app.sh β ββ β configure-nginx β configure/nginx.sh β ββ β health-check β health/check-web.sh β ββ ββββββββββββββββββββ΄βββββββββββββββββββββββββββββββββββ ββ ββ [Edit] [Delete] ββ ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββPermissions
Section titled βPermissionsβServer Process
Section titled βServer ProcessβThe Mantis server process must have read access to the storage directory:
# Check current permissionsls -la /var/mantis/scripts/
# Set appropriate ownershipchown -R mantis:mantis /var/mantis/scripts/
# Set appropriate permissionschmod -R 755 /var/mantis/scripts/Permission Requirements
Section titled βPermission Requirementsβ| Action | Permission Needed |
|---|---|
| Read scripts | r (read) |
| List directory | r and x (read + execute on directory) |
SELinux/AppArmor
Section titled βSELinux/AppArmorβIf using SELinux or AppArmor, ensure the Mantis process has access:
# SELinux examplesemanage fcontext -a -t mantis_script_t "/var/mantis/scripts(/.*)?"restorecon -Rv /var/mantis/scripts/Managing Scripts
Section titled βManaging ScriptsβAdding Scripts
Section titled βAdding ScriptsβScripts can be added directly to the filesystem:
# Copy script to storagecp deploy.sh /var/mantis/scripts/deploy/
# Set executable permissionchmod +x /var/mantis/scripts/deploy/deploy.shUpdating Scripts
Section titled βUpdating ScriptsβUpdate scripts in place:
# Edit scriptvim /var/mantis/scripts/deploy/web-app.sh
# Or copy updated versioncp ~/new-deploy.sh /var/mantis/scripts/deploy/web-app.shRemoving Scripts
Section titled βRemoving Scriptsβ# Remove scriptrm /var/mantis/scripts/deploy/old-script.shMulti-Server Deployments
Section titled βMulti-Server DeploymentsβChallenge
Section titled βChallengeβLocal storage doesnβt automatically sync across multiple Mantis servers:
βββββββββββββββββββ ββββββββββββββββββββ Mantis Server 1β β Mantis Server 2ββ βββββββββββββ β β βββββββββββββ ββ β /scripts/ β β ? β β /scripts/ β ββ β deploy.sh β β βββββ β β (empty) β ββ βββββββββββββ β β βββββββββββββ ββββββββββββββββββββ βββββββββββββββββββSolutions
Section titled βSolutionsβ| Solution | Description |
|---|---|
| Shared filesystem | NFS, EFS, or similar network filesystem |
| Configuration management | Ansible, Puppet, Chef to sync scripts |
| Git storage | Use Git storage instead for automatic sync |
| S3 storage | Use S3 storage for centralized access |
Shared Filesystem Example
Section titled βShared Filesystem Exampleβ# Mount NFS share for scriptsmount -t nfs storage-server:/exports/scripts /var/mantis/scripts
# Add to fstab for persistenceecho "storage-server:/exports/scripts /var/mantis/scripts nfs defaults 0 0" >> /etc/fstabBest Practices
Section titled βBest Practicesβ1. Use Absolute Paths
Section titled β1. Use Absolute PathsβAlways configure with absolute paths:
| Good | Avoid |
|---|---|
/var/mantis/scripts | ./scripts |
/home/deploy/scripts | ~/scripts |
/opt/mantis/scripts | scripts/ |
2. Consistent Directory Structure
Section titled β2. Consistent Directory StructureβOrganize scripts logically:
/var/mantis/scripts/βββ by-solution/ # Organized by solutionβ βββ customer-portal/β βββ auth-service/βββ by-action/ # Organized by action typeβ βββ deploy/β βββ configure/β βββ rollback/βββ shared/ # Common scripts βββ utilities.sh3. Version Control Externally
Section titled β3. Version Control ExternallyβIf using local storage, maintain version control separately:
# Keep scripts in Git repositorycd /var/mantis/scriptsgit initgit add .git commit -m "Initial scripts"4. Backup Regularly
Section titled β4. Backup RegularlyβInclude local storage in backup strategy:
# Backup scriptstar -czvf scripts-backup-$(date +%Y%m%d).tar.gz /var/mantis/scripts/Troubleshooting
Section titled βTroubleshootingββFile not foundβ Error
Section titled ββFile not foundβ ErrorβCause: Script doesnβt exist at specified path
Solution:
- Verify file exists:
ls -la /var/mantis/scripts/deploy.sh - Check filename is correct (case-sensitive)
- Ensure path includes subdirectories if used
βPermission deniedβ Error
Section titled ββPermission deniedβ ErrorβCause: Mantis process lacks read permission
Solution:
- Check file permissions:
ls -la /var/mantis/scripts/ - Fix ownership:
chown mantis:mantis /var/mantis/scripts/* - Fix permissions:
chmod 755 /var/mantis/scripts/*
Storage Not Accessible After Restart
Section titled βStorage Not Accessible After RestartβCause: Path changed or mount point not restored
Solution:
- Verify mount is active:
mount | grep scripts - Check fstab for persistent mounts
- Remount if needed:
mount -a
Next Steps
Section titled βNext Stepsβ- Git Storage - Version-controlled scripts
- S3 Storage - Cloud artifact storage
- Overview - Return to storage overview
