Skip to content

bjwie/ssh-parameter-manager

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

27 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ”§ SSH Parameter Manager

License: MIT Python 3.8+ Flask Code Style: Black CI/CD Auto-Init Tests

SSH Parameter Manager Logo

A professional web-based tool for managing Symfony parameters.yml files across multiple servers via SSH connections. Perfect for DevOps teams managing multiple customer environments with automatic initialization and real-time status updates.

πŸ“Έ Screenshot

SSH Parameter Manager Interface

Modern web interface for managing Symfony parameters across multiple servers with real-time status monitoring, automatic loading, and bulk operations.

πŸ†• New Auto-Initialization Features

Auto-Initialization and Dual View Modes

Latest interface showcasing automatic status loading (2 customers, 1 connected server), dual view modes (VSCode Edition vs Classical View), and Monaco Editor integration with YAML syntax highlighting - all loaded automatically without manual refresh!

✨ Features

  • 🌐 Modern Web Interface - Intuitive, responsive design with automatic data loading
  • ⚑ Auto-Initialization - Automatic status and customer loading without manual refresh
  • πŸ” SSH-Based Remote Access - Secure connections to multiple servers
  • πŸ‘₯ Multi-Customer Support - Manage parameters for multiple customers/projects
  • πŸ“¦ Automatic Backups - Timestamped backups before any changes
  • πŸ”’ Permission Preservation - Maintains file ownership and permissions
  • ⚑ Bulk Operations - Update multiple customers simultaneously
  • 🎯 Template System - Predefined parameter sets for common operations
  • πŸ“Š Real-time Status - Live connection status and operation feedback
  • πŸ”‘ Secret Generation - Built-in secure secret key generator
  • πŸ“ Comprehensive Logging - Detailed operation logs for auditing
  • 🎨 Dual View Modes - Modern Monaco Editor and Classic view options
  • πŸ§ͺ Comprehensive Testing - Extensive test suite with CI/CD integration

πŸš€ Quick Start

Prerequisites

  • Python 3.8 or higher
  • SSH access to target servers
  • Symfony projects with parameters.yml files

Installation

  1. Clone the repository

    git clone https://github.com/bjwie/ssh-parameter-manager.git
    cd ssh-parameter-manager
  2. Create virtual environment

    python -m venv venv
    source venv/bin/activate  # On Windows: venv\Scripts\activate
  3. Install dependencies

    pip install -r requirements.txt
  4. Configure SSH settings

    cp ssh_config.example.yml ssh_config.yml
    # Edit ssh_config.yml with your server and customer details
  5. Start the web server

    python web_server.py
  6. Open your browser

    http://localhost:5000
    

The interface will automatically load all server status and customer information - no manual refresh required!

πŸ”„ Auto-Initialization Feature

The SSH Parameter Manager now features automatic initialization that ensures data is loaded immediately when you open the web interface:

Key Benefits

  • No Manual Refresh Required - Server status and customers load automatically
  • Monaco Editor Independent - Works even if CDN resources fail to load
  • Dual Loading Strategy - Both DOMContentLoaded and Monaco Editor callbacks ensure reliability
  • Error Resilient - Graceful degradation when SSH connections fail
  • Performance Optimized - Concurrent API requests for faster loading

How It Works

// Automatic initialization on page load
document.addEventListener('DOMContentLoaded', function() {
    loadSystemStatus();
    setupClassicEventListeners();
});

The system loads:

  1. Server Connection Status - Real-time SSH connection monitoring
  2. Customer List - All configured customers with their details
  3. Parameter Data - Available parameter files and their status
  4. System Statistics - Total customers, connected servers, etc.

πŸ§ͺ Testing Framework

Comprehensive testing ensures reliability and quality:

Test Suites

  • Unit Tests (16 tests) - JavaScript logic, API endpoints, timing, robustness
  • Browser Tests (8 tests) - Selenium-based end-to-end testing
  • Performance Tests - Page load times, API response times, concurrent requests
  • Integration Tests - Full system integration and error handling

Running Tests

# Run all auto-initialization tests
python tests/run_auto_init_tests.py

# Run specific test categories
python tests/run_auto_init_tests.py --unit
python tests/run_auto_init_tests.py --browser
python tests/run_auto_init_tests.py --performance
python tests/run_auto_init_tests.py --integration

# Run with pytest and coverage
pytest --cov=. --cov-report=xml --cov-report=html tests/

Test Results Example

πŸ§ͺ Running Unit Tests for Auto-Initialization...
βœ… 16/16 tests passed

🌐 Running Browser Tests for Auto-Initialization...
βœ… Browser tests skipped (Selenium not available)

⚑ Running Performance Tests...
βœ… Page load: 0.8s, API responses: < 2s

πŸ”— Running Integration Tests...
βœ… All initialization elements present

πŸŽ‰ All automatic initialization tests passed!

πŸ“‹ Configuration

SSH Configuration File

Create ssh_config.yml based on the example file:

servers:
  production:
    host: your-server.com
    port: 22
    username: deploy
    description: "Production Server"

customers:
  customer1:
    server: production
    path: /var/www/customer1/app/config/parameters.yml
    description: "Customer 1 - E-commerce Platform"

SSH Key Setup

Ensure your SSH keys are properly configured:

# Generate SSH key if needed
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"

# Copy public key to servers
ssh-copy-id user@your-server.com

πŸ–₯️ Usage

Web Interface

The web interface provides automatic loading and:

  • Customer Overview - Auto-populated visual list of all customers
  • Parameter Editor - Monaco Editor with syntax highlighting and validation
  • Classic View - Traditional form-based editing for simple workflows
  • Bulk Operations - Update multiple customers at once
  • Status Monitoring - Real-time connection and operation status
  • Backup Management - Create and manage configuration backups

View Modes

Modern View (Monaco Editor)

  • Advanced code editor with syntax highlighting
  • YAML validation and error detection
  • Auto-completion and formatting
  • Diff view for comparing changes

Classic View

  • Simple form-based interface
  • Quick parameter updates
  • Ideal for non-technical users
  • Mobile-friendly design

Command Line Interface

For automation and scripting:

# List all customers
python ssh_manager.py --list

# Update specific parameter
python ssh_manager.py --update production:customer1 --param database_host=new-server.com

# Apply template to multiple customers
python ssh_manager.py --template database_migration --targets production:customer1,production:customer2

# Create backups for all customers
python ssh_manager.py --backup-all

πŸ—οΈ Architecture

ssh-parameter-manager/
β”œβ”€β”€ web_server.py                    # Flask web application with auto-init
β”œβ”€β”€ ssh_manager.py                   # Core SSH management logic
β”œβ”€β”€ parameter_updater.py            # Parameter file operations
β”œβ”€β”€ ssh_web_interface.html          # Modern web interface with auto-loading
β”œβ”€β”€ ssh_config.yml                  # Configuration file (create from example)
β”œβ”€β”€ requirements.txt                # Python dependencies
β”œβ”€β”€ tests/                          # Comprehensive test suite
β”‚   β”œβ”€β”€ test_auto_initialization.py       # Browser tests (Selenium)
β”‚   β”œβ”€β”€ test_auto_initialization_unit.py  # Unit tests
β”‚   β”œβ”€β”€ run_auto_init_tests.py           # Test orchestration
β”‚   └── README_AUTO_INIT_TESTS.md        # Testing documentation
β”œβ”€β”€ .github/workflows/              # CI/CD pipelines
β”‚   β”œβ”€β”€ ci.yml                      # Main CI/CD pipeline
β”‚   └── auto-init-tests.yml         # Auto-initialization tests
└── README.md                       # This file

πŸ”§ API Endpoints

The Flask backend provides RESTful API endpoints with automatic initialization support:

  • GET /api/status - System and connection status (auto-loaded)
  • GET /api/customers - List all customers (auto-loaded)
  • GET /api/customer/{id}/parameters - Get customer parameters
  • POST /api/customer/{id}/parameters - Update customer parameters
  • POST /api/bulk-update - Bulk parameter updates
  • POST /api/backup/{id} - Create customer backup
  • POST /api/generate-secret - Generate secure secret key

All endpoints support concurrent requests and graceful error handling for reliable auto-initialization.

πŸ›‘οΈ Security Features

  • SSH Key Authentication - Secure, password-less connections
  • Permission Preservation - Maintains original file permissions
  • Backup System - Automatic backups before changes
  • Input Validation - Sanitized parameter inputs
  • Audit Logging - Comprehensive operation logging
  • Secret Generation - Cryptographically secure secret keys
  • Error Handling - Graceful degradation when services are unavailable

πŸš€ Continuous Integration

GitHub Actions workflows ensure code quality:

Main CI/CD Pipeline

  • Python 3.8, 3.9, 3.10, 3.11 compatibility testing
  • Dependency installation and validation
  • Code style checking with Black
  • Security scanning with Safety
  • Automated testing on pull requests

Auto-Initialization Testing

  • Browser compatibility testing (Chrome/ChromeDriver)
  • Headless Selenium tests in CI environment
  • Performance benchmarking
  • Cross-platform compatibility (Ubuntu, macOS, Windows)

πŸ” Troubleshooting

Common Issues

Auto-Initialization Not Working

# Check browser console for JavaScript errors
# Verify API endpoints are responding:
curl http://localhost:5000/api/status
curl http://localhost:5000/api/customers

SSH Connection Failed

# Test SSH connection manually
ssh -i ~/.ssh/id_rsa user@server.com

# Check SSH agent
ssh-add -l

Permission Denied

# Ensure correct file permissions
chmod 600 ~/.ssh/id_rsa
chmod 644 ~/.ssh/id_rsa.pub

Monaco Editor Not Loading

  • The system will fall back to classic view automatically
  • Check internet connection for CDN resources
  • Verify browser JavaScript is enabled

YAML Parsing Error

  • Verify YAML syntax in configuration files
  • Check for proper indentation (spaces, not tabs)

Debug Mode

Enable debug logging:

# In ssh_config.yml
logging:
  level: DEBUG

Run tests to verify functionality:

# Test auto-initialization specifically
python tests/run_auto_init_tests.py --all

# Test with verbose output
python tests/run_auto_init_tests.py --unit --verbose

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Development Workflow

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Run the test suite (python tests/run_auto_init_tests.py --all)
  4. Commit your changes (git commit -m 'Add some AmazingFeature')
  5. Push to the branch (git push origin feature/AmazingFeature)
  6. Open a Pull Request

Testing Requirements

All contributions should include:

  • Unit tests for new functionality
  • Integration tests for API changes
  • Browser tests for UI modifications
  • Documentation updates

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

  • Built for Symfony framework parameter management
  • Inspired by DevOps automation needs
  • Uses Flask for the web interface with auto-initialization
  • Paramiko for SSH connections
  • Monaco Editor for advanced code editing
  • Selenium for comprehensive browser testing

πŸ“ž Support

If you encounter any issues or have questions:

  1. Check the troubleshooting section
  2. Run the diagnostic tests (python tests/run_auto_init_tests.py --all)
  3. Search existing GitHub issues
  4. Create a new issue with detailed information including:
    • Test results output
    • Browser console errors (if applicable)
    • SSH configuration (without sensitive data)

πŸ“ˆ Performance

The auto-initialization system is optimized for performance:

  • Page Load Time: < 3 seconds (target)
  • API Response Time: < 2 seconds per endpoint
  • Concurrent Requests: Supports 5+ simultaneous connections
  • Error Recovery: Automatic retry with exponential backoff
  • Caching: Intelligent caching of customer data and status

Made with ❀️ for the DevOps community - Now with automatic everything! πŸš€

About

A professional tool for managing Symfony parameters.yml files via SSH

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages