#!/bin/bash # Task to Install Docker on an Alpine VM (alpine::install_docker) # Input Variables INSTALL_DOCKER="${PT_install_docker_bool}" STAGING_IP="${PT_staging_ip}" # Check if Docker installation is requested if [ "$INSTALL_DOCKER" != "true" ]; then # Output JSON that Bolt will understand echo '{"status": "skipped", "message": "Docker installation not requested, skipping..."}' exit 0 fi # Update package list and install Docker ssh -o StrictHostKeyChecking=no root@${STAGING_IP} "apk update && apk add --no-cache docker docker-cli docker-cli-compose" # Add current user to docker group ssh -o StrictHostKeyChecking=no root@${STAGING_IP} "addgroup moeny docker" # Start and enable Docker service ssh -o StrictHostKeyChecking=no root@${STAGING_IP} "rc-service docker start && rc-update add docker default" # Verify installation if ssh -o StrictHostKeyChecking=no root@${STAGING_IP} "docker --version" > /dev/null 2>&1; then echo '{"status": "success", "message": "Docker installed successfully"}' exit 0 else echo '{"status": "failure", "message": "Docker installation failed"}' exit 1 fi