How bhagwandas786/automated-apache-on-docker-with-ansible works
Project Type and Purpose
• Type: Infrastructure‐as‐Code (Ansible playbook) that automates Docker installation and Apache container deployment on remote Linux hosts.
• Purpose: Provide a repeatable, version‐controlled method to install Docker, pull an httpd image, run an Apache container, and map port 80 on target servers.
File Structure
• Top‐level files:
• LICENSE – MIT license
• README.md – project overview and instructions
• docker-httpd.yml – the Ansible playbook
• No “frontend/backend” code—this is purely orchestration and configuration management.
README Insights
• Key components: Ansible control host, inventory of target webservers, Docker installation, httpd container deployment.
• External dependencies: community.docker Ansible collection, Docker Hub registry, SSH connectivity.
Main Components & Their Roles
a. Ansible Control Node
• Holds docker-httpd.yml playbook and inventory.ini.
• Runs ansible-playbook over SSH.
b. Inventory & SSH Transport
• inventory.ini lists [webservers] group.
• SSH connection from control node to each target host.
c. Target Hosts (Webservers)
• Execute tasks: install Docker (apt or yum), start/enable Docker service.
• Use community.docker modules to pull httpd:latest and run the Apache container.
d. Docker Hub Registry
• Source of the httpd image.
e. Apache Container
• Listens on container port 80, mapped to host port 80.
f. End Users / Clients
• HTTP requests to http://<server_ip> hit the containerized Apache web server.
Relationships & Data Flows
• Control Node → (SSH) → Target Hosts: sends playbook tasks.
• Target Hosts → (Docker API) → Docker Engine: executes install/pull/run commands.
• Target Hosts ↔ Docker Hub: pulls httpd:latest image.
• End Users → (HTTP) → Host Port 80 → Container Port 80: serve web content.
Architectural Patterns & Design Principles
• Infrastructure-as-Code: declarative tasks in YAML.
• Idempotent provisioning: tasks guard against re-installation if already present.
• Modularity: each playbook task performs a single responsibility (install Docker, start service, pull image, run container).
• External service integration: Docker Hub as artifact registry.