# alvarovaca/ansible-tfg architecture

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

- Interactive diagram: https://gitdiagram.com/alvarovaca/ansible-tfg
- Repository: https://github.com/alvarovaca/ansible-tfg

## Overview

##### Project type and purpose
- This is an Ansible-based infrastructure-as-code project whose goal is to provision a high-availability distributed file system (Ceph) managed by Pacemaker, with supporting services (DNS, common OS hardening, etc.).
- The README points to an article on “Alta disponibilidad de sistemas ficheros distribuidos” (high-availability distributed file systems), confirming that the playbooks and roles glue together Ceph, Pacemaker, DNS, and general host configuration.

##### File structure
- Top‐level:
- ansible.cfg ‑ Ansible configuration
- hosts ‑ inventory defining groups of managed hosts
- pre.yml / post.yml ‑ orchestration playbooks executed before/after the main run
- group_vars/all ‑ variables applied to all hosts
- roles/:
- common: basic OS setup, handlers & tasks
- dns: installs/configures BIND, serves internal zone
- ceph: deploys Ceph monitors, OSDs, keyrings
- pacemaker: configures Pacemaker cluster for resource management
- Each role has tasks/main.yml, handlers, plus any files/templates (e.g., named.conf, Jinja2 templates for DNS zones or Ceph configs).

##### README for additional insights
- The linked blog describes an architecture where:
- A small Ceph monitor quorum ensures cluster metadata integrity
- OSD daemons serve the distributed data
- Pacemaker provides failover and fencing for monitor and OSD instances
- DNS resolves the Ceph cluster endpoints reliably

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Ansible Control Node and Roles
    subgraph "Ansible Control Node"
        direction TB
        ANS_CFG["ansible.cfg"]:::orchestration
        HOSTS["hosts"]:::orchestration
        GROUPVARS["group_vars/all"]:::orchestration
        PRE["pre.yml"]:::orchestration
        subgraph "Role: common"
            direction TB
            COM_TASK["tasks/main.yml"]:::orchestration
            COM_HAND["handlers/main.yml"]:::orchestration
        end
        subgraph "Role: dns"
            direction TB
            DNS_TASK["tasks/main.yml"]:::dns
            DNS_HAND["handlers/main.yml"]:::dns
            DNS_CONF1["named.conf.local"]:::dns
            DNS_CONF2["named.conf.options"]:::dns
            DNS_TEMPLATE["db.example.com.j2"]:::dns
        end
        subgraph "Role: ceph"
            direction TB
            CEPH_TASK["tasks/main.yml"]:::compute
            CEPH_KEY1["ansible_rsa"]:::compute
            CEPH_KEY2["ansible_rsa.pub"]:::compute
        end
        subgraph "Role: pacemaker"
            direction TB
            PAC_TASK["tasks/main.yml"]:::pacemaker
            PAC_HAND["handlers/main.yml"]:::pacemaker
            PAC_CONF["prestashop.conf"]:::pacemaker
        end
        POST["post.yml"]:::orchestration
    end

    %% Managed Hosts
    subgraph "Ceph Monitor Quorum" 
        direction TB
        MON1["Mon1"]:::compute
        MON2["Mon2"]:::compute
        MON3["Mon3"]:::compute
    end

    subgraph "Ceph OSD Cluster"
        direction TB
        OSD1["OSD1"]:::compute
        OSD2["OSD2"]:::compute
    end

    subgraph "Pacemaker Cluster"
        direction TB
        PC1["Node1"]:::pacemaker
        PC2["Node2"]:::pacemaker
    end

    subgraph "DNS Servers"
        direction TB
        DNS1["DNS1"]:::dns
        DNS2["DNS2"]:::dns
    end

    %% Network and External
    EXT_CLIENTS["External Clients"]:::external
    PUB_NET["Public/Client Network"]:::network
    CLUSTER_NET["Private/Cluster Network"]:::network

    %% Orchestration Flow
    PRE -->|runs playbooks| COM_TASK -->|then| DNS_TASK -->|then| CEPH_TASK -->|then| PAC_TASK -->|finalize| POST

    %% SSH Push to Hosts
    POST -->|SSH| MON1
    POST -->|SSH| MON2
    POST -->|SSH| MON3
    POST -->|SSH| OSD1
    POST -->|SSH| OSD2
    POST -->|SSH| PC1
    POST -->|SSH| PC2
    POST -->|SSH| DNS1
    POST -->|SSH| DNS2

    %% Data and Health Flows
    EXT_CLIENTS -->|Ceph RBD/CephFS/RGW| PUB_NET
    PUB_NET -->|client traffic| OSD1
    PUB_NET -->|client traffic| OSD2
    PUB_NET -->|metadata| MON1
    PUB_NET -->|metadata| MON2
    PUB_NET -->|metadata| MON3
    CLUSTER_NET -->|replication & heartbeat| MON1
    CLUSTER_NET -->|replication & heartbeat| MON2
    CLUSTER_NET -->|replication & heartbeat| MON3
    CLUSTER_NET -->|fencing & monitoring| PC1
    CLUSTER_NET -->|fencing & monitoring| PC2
    DNS1 -->|DNS queries| PUB_NET
    DNS2 -->|DNS queries| PUB_NET

    %% Click Events
    click ANS_CFG "https://github.com/alvarovaca/ansible-tfg/blob/main/ansible.cfg"
    click HOSTS "https://github.com/alvarovaca/ansible-tfg/tree/main/hosts"
    click GROUPVARS "https://github.com/alvarovaca/ansible-tfg/tree/main/group_vars/all"
    click PRE "https://github.com/alvarovaca/ansible-tfg/blob/main/pre.yml"
    click POST "https://github.com/alvarovaca/ansible-tfg/blob/main/post.yml"
    click COM_TASK "https://github.com/alvarovaca/ansible-tfg/blob/main/roles/common/tasks/main.yml"
    click COM_HAND "https://github.com/alvarovaca/ansible-tfg/blob/main/roles/common/handlers/main.yml"
    click DNS_TASK "https://github.com/alvarovaca/ansible-tfg/blob/main/roles/dns/tasks/main.yml"
    click DNS_HAND "https://github.com/alvarovaca/ansible-tfg/blob/main/roles/dns/handlers/main.yml"
    click DNS_CONF1 "https://github.com/alvarovaca/ansible-tfg/blob/main/roles/dns/files/named.conf.local"
    click DNS_CONF2 "https://github.com/alvarovaca/ansible-tfg/blob/main/roles/dns/files/named.conf.options"
    click DNS_TEMPLATE "https://github.com/alvarovaca/ansible-tfg/blob/main/roles/dns/templates/db.example.com.j2"
    click CEPH_TASK "https://github.com/alvarovaca/ansible-tfg/blob/main/roles/ceph/tasks/main.yml"
    click CEPH_KEY1 "https://github.com/alvarovaca/ansible-tfg/tree/main/roles/ceph/files/ansible_rsa"
    click CEPH_KEY2 "https://github.com/alvarovaca/ansible-tfg/blob/main/roles/ceph/files/ansible_rsa.pub"
    click PAC_TASK "https://github.com/alvarovaca/ansible-tfg/blob/main/roles/pacemaker/tasks/main.yml"
    click PAC_HAND "https://github.com/alvarovaca/ansible-tfg/blob/main/roles/pacemaker/handlers/main.yml"
    click PAC_CONF "https://github.com/alvarovaca/ansible-tfg/blob/main/roles/pacemaker/files/prestashop.conf"

    %% Styles
    classDef orchestration fill:#8fbc8f,stroke:#333,stroke-width:2px;
    classDef compute fill:#add8e6,stroke:#333,stroke-width:2px;
    classDef dns fill:#ffa500,stroke:#333,stroke-width:2px;
    classDef pacemaker fill:#dda0dd,stroke:#333,stroke-width:2px;
    classDef network fill:#d3d3d3,stroke:#333,stroke-width:2px;
    classDef external fill:#ffb6c1,stroke:#333,stroke-width:2px;
```
