# abhijitsharma806/aws-ansible-mysql-nginx-apache-wordpress architecture

> Architecture diagram of the GitHub repository abhijitsharma806/aws-ansible-mysql-nginx-apache-wordpress, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-08-04). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/abhijitsharma806/aws-ansible-mysql-nginx-apache-wordpress
- Repository: https://github.com/abhijitsharma806/aws-ansible-mysql-nginx-apache-wordpress

## Overview

##### Project Type and Purpose
- This is an infrastructure-as-code project using Ansible to provision and configure an AWS VPC, EC2 instances, networking (public/private subnets, NAT), services (Nginx load balancer, Apache HTTPD, MySQL master‐slave, WordPress), and an intermediate Ansible bastion server.
- README describes end-to-end automation: create VPC, subnets, NAT, EC2 launch, configure load‐balancer, database replication, Wordpress master & slave installations.

##### File Structure Analysis
- Top‐level:
- aws-ansible.yml – main playbook orchestrating four sequential sections.
- ansible.cfg, hosts – client configuration.
- roles/ – broken down by concern:
– ec2-launch: AWS resource creation (VPC, EC2, key pairs)
– hostip: inventory population scripts
– nginx-lb: Nginx LB installation & config
– ansibleserver: configures bastion Ansible server
– apache: installs Apache on private subnet servers
– master/slave: MySQL master/slave setup, replication scripts & templates
– wordpress, wordpress-slave: WordPress installs pointing to master or slave
– dbscript: data dump and replication‐position retrieval
- Patterns: modular roles (Separation of Concerns), sequential playbook sections, IaC for networking and config.

##### Key README Insights
- Four distinct playbook phases run in order from local then bastion:
1. ec2-launch & hostip (infrastructure provisioning)
2. nginx-lb & ansibleserver (LB & bastion setup)
3. apache, master, wordpress, dbscript (web+DB master+WordPress)
4. slave & wordpress-slave (DB slave + readonly WordPress)
- Technologies: AWS EC2/VPC, Ansible, Nginx, Apache, MySQL (MariaDB), WordPress, Bash scripts.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External control plane
    Local["Local Ansible Control (Phases 1-4)"]:::ansible
    Client["Internet User"]:::external

    %% AWS Cloud Boundary
    subgraph "AWS Cloud" class cloud
        subgraph "VPC (172.16.0.0/16)"
            subgraph "Public Subnet (172.16.0.0/24)" class subnet-public
                NLB["Nginx Load Balancer"]:::compute
                Bastion["Ansible Bastion Server"]:::compute
            end
            subgraph "Private Subnet (172.16.1.0/24)" class subnet-private
                WebMaster["Apache + WordPress Master"]:::compute
                DBMaster["MySQL Master"]:::db
                WebSlave["Apache + WordPress Slave"]:::compute
                DBSlave["MySQL Slave"]:::db
            end
            NAT["NAT Gateway"]:::compute
        end
    end

    %% Data and control flows
    Client -->|HTTP/HTTPS| NLB:::flow-data
    NLB -->|Forward requests| WebMaster:::flow-data
    NLB -->|Forward requests| WebSlave:::flow-data

    WebMaster -->|Reads/Writes| DBMaster:::flow-data
    DBMaster -->|Replication| DBSlave:::flow-data
    WebSlave -->|Reads| DBSlave:::flow-data

    Local -->|Run aws-ansible.yml| awsansible:::ansible
    Local -->|SSH/Ansible| Bastion:::flow-control
    Bastion -->|SSH/Ansible| NLB:::flow-control
    Bastion -->|SSH/Ansible| WebMaster:::flow-control
    Bastion -->|SSH/Ansible| DBMaster:::flow-control
    Bastion -->|SSH/Ansible| WebSlave:::flow-control
    Bastion -->|SSH/Ansible| DBSlave:::flow-control

    %% Playbook node
    awsansible["aws-ansible.yml"]:::ansible

    %% Click Events
    click awsansible "https://github.com/abhijitsharma806/aws-ansible-mysql-nginx-apache-wordpress/blob/master/aws-ansible.yml"
    click ansiblecfg "https://github.com/abhijitsharma806/aws-ansible-mysql-nginx-apache-wordpress/blob/master/ansible.cfg"
    click hosts "https://github.com/abhijitsharma806/aws-ansible-mysql-nginx-apache-wordpress/tree/master/hosts"
    click ec2Tasks "https://github.com/abhijitsharma806/aws-ansible-mysql-nginx-apache-wordpress/blob/master/roles/ec2-launch/tasks/main.yml"
    click ec2Defaults "https://github.com/abhijitsharma806/aws-ansible-mysql-nginx-apache-wordpress/blob/master/roles/ec2-launch/defaults/main.yml"
    click ec2Vars "https://github.com/abhijitsharma806/aws-ansible-mysql-nginx-apache-wordpress/blob/master/roles/ec2-launch/vars/main.yml"
    click ec2Key "https://github.com/abhijitsharma806/aws-ansible-mysql-nginx-apache-wordpress/blob/master/roles/ec2-launch/mykey.pem"
    click hostipTasks "https://github.com/abhijitsharma806/aws-ansible-mysql-nginx-apache-wordpress/blob/master/roles/hostip/tasks/main.yml"
    click hostipDefaults "https://github.com/abhijitsharma806/aws-ansible-mysql-nginx-apache-wordpress/blob/master/roles/hostip/defaults/main.yml"
    click nginxTasks "https://github.com/abhijitsharma806/aws-ansible-mysql-nginx-apache-wordpress/blob/master/roles/nginx-lb/tasks/main.yml"
    click nginxConf "https://github.com/abhijitsharma806/aws-ansible-mysql-nginx-apache-wordpress/blob/master/roles/nginx-lb/templates/default.conf.j2"
    click nginxRepo "https://github.com/abhijitsharma806/aws-ansible-mysql-nginx-apache-wordpress/blob/master/roles/nginx-lb/templates/nginx.repo.j2"
    click nginxScript "https://github.com/abhijitsharma806/aws-ansible-mysql-nginx-apache-wordpress/blob/master/roles/nginx-lb/script.sh"
    click bastionTasks "https://github.com/abhijitsharma806/aws-ansible-mysql-nginx-apache-wordpress/blob/master/roles/ansibleserver/tasks/main.yml"
    click bastionDefaults "https://github.com/abhijitsharma806/aws-ansible-mysql-nginx-apache-wordpress/blob/master/roles/ansibleserver/defaults/main.yml"
    click apacheTasks "https://github.com/abhijitsharma806/aws-ansible-mysql-nginx-apache-wordpress/blob/master/roles/apache/tasks/main.yml"
    click apacheIndex "https://github.com/abhijitsharma806/aws-ansible-mysql-nginx-apache-wordpress/blob/master/roles/apache/templates/index.html.j2"
    click masterTasks "https://github.com/abhijitsharma806/aws-ansible-mysql-nginx-apache-wordpress/blob/master/roles/master/tasks/main.yml"
    click masterScript "https://github.com/abhijitsharma806/aws-ansible-mysql-nginx-apache-wordpress/blob/master/roles/master/dbscript.sh"
    click masterMyCnf "https://github.com/abhijitsharma806/aws-ansible-mysql-nginx-apache-wordpress/blob/master/roles/master/templates/my.cnf.j2"
    click masterDotMyCnf "https://github.com/abhijitsharma806/aws-ansible-mysql-nginx-apache-wordpress/blob/master/roles/master/templates/.my.cnf.j2"
    click masterRootMyCnf "https://github.com/abhijitsharma806/aws-ansible-mysql-nginx-apache-wordpress/blob/master/roles/master/templates/root-my.cnf.j2"
    click masterUserMyCnf "https://github.com/abhijitsharma806/aws-ansible-mysql-nginx-apache-wordpress/blob/master/roles/master/templates/user-my.cnf.j2"
    click dbscriptTasks "https://github.com/abhijitsharma806/aws-ansible-mysql-nginx-apache-wordpress/blob/master/roles/dbscript/tasks/main.yml"
    click dbscriptDefaults "https://github.com/abhijitsharma806/aws-ansible-mysql-nginx-apache-wordpress/blob/master/roles/dbscript/defaults/main.yml"
    click slaveTasks "https://github.com/abhijitsharma806/aws-ansible-mysql-nginx-apache-wordpress/blob/master/roles/slave/tasks/main.yml"
    click slaveMyCnf "https://github.com/abhijitsharma806/aws-ansible-mysql-nginx-apache-wordpress/blob/master/roles/slave/templates/my.cnf.j2"
    click slaveDotMyCnf "https://github.com/abhijitsharma806/aws-ansible-mysql-nginx-apache-wordpress/blob/master/roles/slave/templates/.my.cnf.j2"
    click slaveRootMyCnf "https://github.com/abhijitsharma806/aws-ansible-mysql-nginx-apache-wordpress/blob/master/roles/slave/templates/root-my.cnf.j2"
    click slaveUserMyCnf "https://github.com/abhijitsharma806/aws-ansible-mysql-nginx-apache-wordpress/blob/master/roles/slave/templates/user-my.cnf.j2"
    click wpMasterTasks "https://github.com/abhijitsharma806/aws-ansible-mysql-nginx-apache-wordpress/blob/master/roles/wordpress/tasks/main.yml"
    click wpMasterConf "https://github.com/abhijitsharma806/aws-ansible-mysql-nginx-apache-wordpress/blob/master/roles/wordpress/templates/wordpress.conf.j2"
    click wpMasterWPConfig "https://github.com/abhijitsharma806/aws-ansible-mysql-nginx-apache-wordpress/blob/master/roles/wordpress/templates/wp-config.php.j2"
    click wpSlaveTasks "https://github.com/abhijitsharma806/aws-ansible-mysql-nginx-apache-wordpress/blob/master/roles/wordpress-slave/tasks/main.yml"
    click wpSlaveConf "https://github.com/abhijitsharma806/aws-ansible-mysql-nginx-apache-wordpress/blob/master/roles/wordpress-slave/templates/wordpress.conf.j2"
    click wpSlaveWPConfig "https://github.com/abhijitsharma806/aws-ansible-mysql-nginx-apache-wordpress/blob/master/roles/wordpress-slave/templates/wp-config.php.j2"

    %% Styles
    classDef cloud fill:#E0F7FA,stroke:#00838F,stroke-width:2px
    classDef subnet-public fill:#E8F5E9,stroke:#2E7D32
    classDef subnet-private fill:#F3E5F5,stroke:#6A1B9A
    classDef compute fill:#FFF9C4,stroke:#F9A825
    classDef db fill:#FFEBEE,stroke:#C62828
    classDef ansible fill:#E1F5FE,stroke:#0288D1,stroke-dasharray: 5 5
    classDef external fill:#ECEFF1,stroke:#546E7A,stroke-dasharray: 5 5
    classDef flow-data stroke:#FF5722,stroke-width:2px
    classDef flow-control stroke:#3F51B5,stroke-width:2px,stroke-dasharray: 5 5
```
