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 |
| File System Path | Yes | Absolute path to scripts directory (field labelled “File System Path”) |
Creating Local Storage
Section titled “Creating Local Storage”Via Lens UI
Section titled “Via Lens UI”┌─────────────────────────────────────────────────────────────┐│ Create Local Storage │├─────────────────────────────────────────────────────────────┤│ ││ Name * ││ [scripts ] ││ ││ File System 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 Local Storage
Via REST API
Section titled “Via REST API”Global-admin tokens must include
tenant_id. Storage creation callsresolve_tenant_id_for_write, which rejects with400 tenant_id is required for storage creationwhen it resolves toNone— exactly the case for an admin token that omits it. Add"tenant_id": "<uuid>"to the request body (or use a tenant-scoped token, which supplies it automatically).
# 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 ││ ││ (The detail page shows Name / ID / Path / Created / Last ││ Updated only — there is no "Used By" consumers list.) │ ││ ││ [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
