A comprehensive collection of automation scripts for DevOps tasks including deployment automation, server monitoring, backup management, and CI/CD pipeline utilities.
pip install -r requirements.txt
Create a config.yaml file:
servers:
- name: production
host: example.com
user: admin
port: 22
key_path: ~/.ssh/id_rsa
monitoring:
check_interval: 300
alert_email: admin@example.com
backup:
destination: /backups
retention_days: 30
deploy.py)Automated deployment to multiple servers:
python deploy.py --environment production --branch main
Features:
monitor.py)Real-time server monitoring:
python monitor.py --continuous
Monitors:
backup.py)Automated backup solution:
python backup.py --type full --compress
Features:
log_analyzer.py)Parse and analyze logs:
python log_analyzer.py --file /var/log/app.log --errors-only
Features:
docker_manager.py)Docker container management:
python docker_manager.py --action restart --service webapp
Features:
devops-automation-suite/
├── scripts/
│ ├── deploy.py # Deployment automation
│ ├── monitor.py # Server monitoring
│ ├── backup.py # Backup management
│ ├── log_analyzer.py # Log analysis
│ └── docker_manager.py # Docker utilities
├── utils/
│ ├── ssh_client.py # SSH operations
│ ├── email_notifier.py # Email notifications
│ ├── logger.py # Logging utilities
│ └── config_loader.py # Configuration management
├── config.yaml.example # Example configuration
└── README.md
# Deploy specific version
python scripts/deploy.py --env production --tag v1.2.3
# Deploy with rollback on failure
python scripts/deploy.py --env staging --rollback-on-error
# One-time check
python scripts/monitor.py --check-once
# Continuous monitoring with alerts
python scripts/monitor.py --continuous --alert-threshold 80
# Full backup
python scripts/backup.py --type database --databases all
# Incremental backup
python scripts/backup.py --type incremental --since yesterday
# Find errors in last hour
python scripts/log_analyzer.py --since "1 hour ago" --level ERROR
# Generate report
python scripts/log_analyzer.py --report --output report.html
Add to crontab for automation:
# Backup every day at 2 AM
0 2 * * * /usr/bin/python3 /path/to/backup.py --type full
# Monitor every 5 minutes
*/5 * * * * /usr/bin/python3 /path/to/monitor.py --check-once
# Clean old logs weekly
0 0 * * 0 /usr/bin/python3 /path/to/log_analyzer.py --cleanup