🎬 ARR Suite Template Bootstrap - Complete Media Automation Stack Features: - 16 production services (Prowlarr, Sonarr, Radarr, Plex, etc.) - One-command Ansible deployment - VPN-protected downloads via Gluetun - Tailscale secure access - Production-ready security (UFW, Fail2Ban) - Automated backups and monitoring - Comprehensive documentation Ready for customization and deployment to any VPS. Co-authored-by: openhands <openhands@all-hands.dev>
221 lines
5.9 KiB
Bash
Executable File
221 lines
5.9 KiB
Bash
Executable File
#!/bin/bash
|
|
# Quick deployment script for *arr Media Stack
|
|
# Usage: ./deploy.sh [environment]
|
|
|
|
set -euo pipefail
|
|
|
|
# Configuration
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
ENVIRONMENT="${1:-production}"
|
|
INVENTORY_FILE="inventory/${ENVIRONMENT}.yml"
|
|
PLAYBOOK_FILE="ansible-deployment.yml"
|
|
|
|
# Colors for output
|
|
RED='\033[0;31m'
|
|
GREEN='\033[0;32m'
|
|
YELLOW='\033[1;33m'
|
|
BLUE='\033[0;34m'
|
|
NC='\033[0m' # No Color
|
|
|
|
# Logging function
|
|
log() {
|
|
echo -e "${BLUE}[$(date +'%Y-%m-%d %H:%M:%S')]${NC} $1"
|
|
}
|
|
|
|
error() {
|
|
echo -e "${RED}[ERROR]${NC} $1" >&2
|
|
}
|
|
|
|
success() {
|
|
echo -e "${GREEN}[SUCCESS]${NC} $1"
|
|
}
|
|
|
|
warning() {
|
|
echo -e "${YELLOW}[WARNING]${NC} $1"
|
|
}
|
|
|
|
# Check prerequisites
|
|
check_prerequisites() {
|
|
log "Checking prerequisites..."
|
|
|
|
# Check if ansible is installed
|
|
if ! command -v ansible &> /dev/null; then
|
|
error "Ansible is not installed. Please install Ansible first."
|
|
exit 1
|
|
fi
|
|
|
|
# Check if inventory file exists
|
|
if [[ ! -f "$INVENTORY_FILE" ]]; then
|
|
error "Inventory file $INVENTORY_FILE not found."
|
|
echo "Please create it from the example:"
|
|
echo "cp inventory/production.yml.example $INVENTORY_FILE"
|
|
exit 1
|
|
fi
|
|
|
|
# Check if vault file exists
|
|
if [[ ! -f "group_vars/all/vault.yml" ]]; then
|
|
warning "Vault file not found. Creating from example..."
|
|
cp group_vars/all/vault.yml.example group_vars/all/vault.yml
|
|
echo "Please edit group_vars/all/vault.yml with your credentials and encrypt it:"
|
|
echo "ansible-vault encrypt group_vars/all/vault.yml"
|
|
exit 1
|
|
fi
|
|
|
|
# Check if playbook exists
|
|
if [[ ! -f "$PLAYBOOK_FILE" ]]; then
|
|
error "Playbook file $PLAYBOOK_FILE not found."
|
|
exit 1
|
|
fi
|
|
|
|
success "Prerequisites check passed!"
|
|
}
|
|
|
|
# Test connectivity
|
|
test_connectivity() {
|
|
log "Testing connectivity to target hosts..."
|
|
|
|
if ansible all -i "$INVENTORY_FILE" -m ping --ask-vault-pass; then
|
|
success "Connectivity test passed!"
|
|
else
|
|
error "Connectivity test failed. Please check your inventory and SSH configuration."
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
# Validate configuration
|
|
validate_config() {
|
|
log "Validating Ansible configuration..."
|
|
|
|
if ansible-playbook -i "$INVENTORY_FILE" "$PLAYBOOK_FILE" --syntax-check; then
|
|
success "Configuration validation passed!"
|
|
else
|
|
error "Configuration validation failed. Please check your playbook syntax."
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
# Run deployment
|
|
deploy_stack() {
|
|
log "Starting deployment of *arr media stack..."
|
|
|
|
# Ask for confirmation
|
|
echo
|
|
echo "🚀 Ready to deploy the complete *arr media stack!"
|
|
echo "Environment: $ENVIRONMENT"
|
|
echo "Inventory: $INVENTORY_FILE"
|
|
echo "Playbook: $PLAYBOOK_FILE"
|
|
echo
|
|
read -p "Continue with deployment? (y/N): " -n 1 -r
|
|
echo
|
|
|
|
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
|
|
warning "Deployment cancelled by user."
|
|
exit 0
|
|
fi
|
|
|
|
# Run the playbook
|
|
if ansible-playbook -i "$INVENTORY_FILE" "$PLAYBOOK_FILE" --ask-vault-pass; then
|
|
success "🎉 Deployment completed successfully!"
|
|
echo
|
|
echo "📊 Your *arr stack is now running!"
|
|
echo "Check the services at the URLs provided in the playbook output."
|
|
echo
|
|
echo "📋 Next steps:"
|
|
echo "1. Configure indexers in Prowlarr"
|
|
echo "2. Connect applications to Prowlarr"
|
|
echo "3. Set up download clients"
|
|
echo "4. Configure Plex libraries"
|
|
echo "5. Set up Jellyseerr for requests"
|
|
echo
|
|
echo "📖 See ANSIBLE_DEPLOYMENT.md for detailed configuration instructions."
|
|
else
|
|
error "Deployment failed. Check the output above for details."
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
# Dry run option
|
|
dry_run() {
|
|
log "Running deployment in check mode (dry run)..."
|
|
|
|
if ansible-playbook -i "$INVENTORY_FILE" "$PLAYBOOK_FILE" --check --ask-vault-pass; then
|
|
success "Dry run completed successfully!"
|
|
echo "No issues found. Ready for actual deployment."
|
|
else
|
|
error "Dry run failed. Please fix the issues before deploying."
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
# Show help
|
|
show_help() {
|
|
cat << EOF
|
|
🚀 *arr Media Stack Deployment Script
|
|
|
|
Usage: $0 [OPTIONS] [ENVIRONMENT]
|
|
|
|
ENVIRONMENTS:
|
|
production Deploy to production environment (default)
|
|
staging Deploy to staging environment
|
|
development Deploy to development environment
|
|
|
|
OPTIONS:
|
|
--check Run in check mode (dry run)
|
|
--test Test connectivity only
|
|
--validate Validate configuration only
|
|
--help Show this help message
|
|
|
|
EXAMPLES:
|
|
$0 # Deploy to production
|
|
$0 staging # Deploy to staging
|
|
$0 --check production # Dry run on production
|
|
$0 --test # Test connectivity
|
|
$0 --validate # Validate configuration
|
|
|
|
PREREQUISITES:
|
|
- Ansible 2.12+ installed
|
|
- SSH key-based authentication configured
|
|
- Inventory file created (inventory/\${ENVIRONMENT}.yml)
|
|
- Vault file configured (group_vars/all/vault.yml)
|
|
|
|
For detailed instructions, see ANSIBLE_DEPLOYMENT.md
|
|
EOF
|
|
}
|
|
|
|
# Main execution
|
|
main() {
|
|
cd "$SCRIPT_DIR"
|
|
|
|
case "${1:-}" in
|
|
--help|-h)
|
|
show_help
|
|
exit 0
|
|
;;
|
|
--check)
|
|
ENVIRONMENT="${2:-production}"
|
|
INVENTORY_FILE="inventory/${ENVIRONMENT}.yml"
|
|
check_prerequisites
|
|
validate_config
|
|
dry_run
|
|
;;
|
|
--test)
|
|
ENVIRONMENT="${2:-production}"
|
|
INVENTORY_FILE="inventory/${ENVIRONMENT}.yml"
|
|
check_prerequisites
|
|
test_connectivity
|
|
;;
|
|
--validate)
|
|
check_prerequisites
|
|
validate_config
|
|
;;
|
|
*)
|
|
check_prerequisites
|
|
validate_config
|
|
test_connectivity
|
|
deploy_stack
|
|
;;
|
|
esac
|
|
}
|
|
|
|
# Run main function with all arguments
|
|
main "$@" |