# bhagwandas786/automated-apache-on-docker-with-ansible architecture

> Architecture diagram of the GitHub repository bhagwandas786/automated-apache-on-docker-with-ansible, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-22). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/bhagwandas786/automated-apache-on-docker-with-ansible
- Repository: https://github.com/bhagwandas786/automated-apache-on-docker-with-ansible

## Overview

##### 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.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Project Files"
        README["README.md"]:::external
        LICENSE["LICENSE"]:::external
    end

    subgraph "Control Node"
        Playbook["Ansible Playbook\ndocker-httpd.yml"]:::control
        Inventory["Inventory\ninventory.ini"]:::control
    end

    subgraph "Target Host"
        DockerEngine["Docker Engine"]:::runtime
        ApacheContainer["Apache Container\nPort 80"]:::runtime
    end

    DockerHub["Docker Hub"]:::external
    EndUser["End User / Client"]:::client

    Playbook -->|"Reads Inventory"| Inventory
    Inventory -->|"SSH (22) Ansible"| DockerEngine
    DockerEngine -->|"Pull httpd:latest"| DockerHub
    DockerEngine -->|"Run Container"| ApacheContainer
    EndUser -->|"HTTP (80)"| ApacheContainer

    click Playbook "https://github.com/bhagwandas786/automated-apache-on-docker-with-ansible/blob/main/docker-httpd.yml"
    click README "https://github.com/bhagwandas786/automated-apache-on-docker-with-ansible/blob/main/README.md"
    click LICENSE "https://github.com/bhagwandas786/automated-apache-on-docker-with-ansible/tree/main/LICENSE"

    classDef control fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef runtime fill:#90EE90,stroke:#333,stroke-width:1px
    classDef external fill:#FFD700,stroke:#333,stroke-width:1px
    classDef client fill:#DDA0DD,stroke:#333,stroke-width:1px
```
