# dynamictivity/docker-ansible architecture

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

- Interactive diagram: https://gitdiagram.com/dynamictivity/docker-ansible
- Repository: https://github.com/dynamictivity/docker-ansible

## Overview

##### Project type and purpose
- This is not a classic frontend/backend app but a containerized automation tool: a disposable Docker-based Ansible control node.
- Its purpose is to build a Docker image that can pull and run Ansible playbooks from local mounts or remote URLs, install Galaxy roles automatically, and execute arbitrary Ansible commands against specified inventories.

##### File structure
- Top level:
- Dockerfile – builds the control-node image
- docker-compose.yml – example service definitions
- my_init/ – custom init scripts run at container startup
- ansible/ – default config (`ansible.cfg`), inventory, playbooks, parameters
- Vagrantfile + vagrant-libs/ + ansible/ – local development and provisioning via Vagrant and Ansible
- CI config: .gitlab-ci.yml
- Patterns & deployment artifacts:
- Docker layers: base OS → Python/Ansible → my_init scripts → entrypoint logic
- Configuration-as-code: ansible.cfg, params.json, inventory, playbooks
- Orchestration: Docker Compose / Vagrant as two alternate local drivers

##### README for insights
- Describes environment variables that drive behavior (ANSIBLE_PLAYBOOK_URL, ANSIBLE_GALAXY_ROLES, etc.)
- Explains three usage modes: direct ansible command, remote playbook & galaxy, or mounting local playbooks/inventory
- Mentions future TODOs: loading remote inventory and configs

##### Essential details
- Both default internal paths (`/ansible`, `/inventory`, `/etc/ansible/ansible.cfg`) and override mounts
- Init sequence: entrypoint → fetch → configure → execute
- Environment variables driving behavior (e.g., ANSIBLE_PLAYBOOK_URL) near the container component

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Developer / CI"
        Dev["Developer"]:::external
        CI["CI/CD System"]:::external
        Vagrant["Vagrant"]:::external
    end

    Dev -->|"run compose or vagrant"| Container
    CI -->|"runs build"| Build["Docker Build"]:::container
    CI -->|"executes pipeline"| CI
    Build --> Image["Control-Node Image"]:::container
    Image --> Container["Control-Node Container"]:::container
    Vagrant -->|"provisions control node"| Container

    subgraph "Control-Node Container"
        Init["Init Script (entrypoint)"]:::container
        Env["Environment Variables"]:::config
        Cfg["ansible.cfg"]:::config
        PlayDir["Playbooks (/ansible)"]:::config
        Roles["roles"]:::config
        MainPlay["site.yml"]:::config
        InvDir["Inventory (/inventory)"]:::config
        InvHosts["hosts"]:::config
        Params["params.json"]:::config
        Exec["Ansible CLI"]:::container

        Container --> Init
        Init --> Env
        Init --> Cfg
        Init --> PlayDir
        Init --> InvDir
        Init --> Params
        PlayDir --> Roles
        PlayDir --> MainPlay
        InvDir --> InvHosts
        Init -->|"triggers"| Exec
    end

    subgraph "External Services"
        Git["Remote Git/HTTP Server"]:::external
        Galaxy["Ansible Galaxy API"]:::external
        Targets["Target Hosts"]:::external
    end

    Git -->|"pull playbook"| Container
    Galaxy -->|"install roles"| Container
    Container -->|"SSH/WinRM"| Targets

    click Build "https://github.com/dynamictivity/docker-ansible/tree/master/Dockerfile"
    click CI "https://github.com/dynamictivity/docker-ansible/blob/master/.gitlab-ci.yml"
    click Init "https://github.com/dynamictivity/docker-ansible/blob/master/my_init/init-ansible.sh"
    click Cfg "https://github.com/dynamictivity/docker-ansible/blob/master/ansible/ansible.cfg"
    click InvDir "https://github.com/dynamictivity/docker-ansible/tree/master/ansible/inventory"
    click InvHosts "https://github.com/dynamictivity/docker-ansible/tree/master/ansible/inventory/hosts"
    click Params "https://github.com/dynamictivity/docker-ansible/blob/master/ansible/params.json"
    click PlayDir "https://github.com/dynamictivity/docker-ansible/tree/master/ansible/playbooks"
    click Roles "https://github.com/dynamictivity/docker-ansible/tree/master/ansible/playbooks/roles"
    click MainPlay "https://github.com/dynamictivity/docker-ansible/blob/master/ansible/site.yml"
    click Vagrant "https://github.com/dynamictivity/docker-ansible/tree/master/Vagrantfile"
    click Vagrant "https://github.com/dynamictivity/docker-ansible/blob/master/vagrant-libs/bootstrap.sh"

    classDef container fill:#ADD8E6,stroke:#000;
    classDef external fill:#D5E8D4,stroke:#000;
    classDef config fill:#FFF2CC,stroke:#000;
```
