{"id":24837936,"url":"https://github.com/abrar-2510/wordpress-docker-ansible-setup","last_synced_at":"2026-02-05T00:34:09.124Z","repository":{"id":265502114,"uuid":"896135574","full_name":"Abrar-2510/WordPress-Docker-Ansible-Setup","owner":"Abrar-2510","description":"This project automates the deployment of a WordPress website with a MySQL database using Ansible and Docker. The setup is portable and can be used across various environments (e.g., AWS, local servers, or any cloud platform). This solution includes setting up Docker, Docker Compose, WordPress, and MySQL as containers.","archived":false,"fork":false,"pushed_at":"2024-11-29T17:19:05.000Z","size":10,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-26T04:29:22.324Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Jinja","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Abrar-2510.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-11-29T16:08:25.000Z","updated_at":"2024-12-07T11:55:04.000Z","dependencies_parsed_at":"2024-11-30T02:54:42.089Z","dependency_job_id":null,"html_url":"https://github.com/Abrar-2510/WordPress-Docker-Ansible-Setup","commit_stats":null,"previous_names":["abrar-2510/depi-2nd-task","abrar-2510/wordpress-docker-ansible-setup"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Abrar-2510/WordPress-Docker-Ansible-Setup","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Abrar-2510%2FWordPress-Docker-Ansible-Setup","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Abrar-2510%2FWordPress-Docker-Ansible-Setup/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Abrar-2510%2FWordPress-Docker-Ansible-Setup/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Abrar-2510%2FWordPress-Docker-Ansible-Setup/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Abrar-2510","download_url":"https://codeload.github.com/Abrar-2510/WordPress-Docker-Ansible-Setup/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Abrar-2510%2FWordPress-Docker-Ansible-Setup/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264315028,"owners_count":23589699,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-01-31T06:07:59.772Z","updated_at":"2026-02-05T00:34:09.050Z","avatar_url":"https://github.com/Abrar-2510.png","language":"Jinja","funding_links":[],"categories":[],"sub_categories":[],"readme":"# WordPress Docker Ansible Setup\n\n## Overview\n\nThis project automates the deployment of a **WordPress** website with a **MySQL** database using **Ansible** and **Docker**. The setup is portable and can be used across various environments (e.g., AWS, local servers, or any cloud platform). This solution includes setting up Docker, Docker Compose, WordPress, and MySQL as containers.\n\n---\n\n```\nwordpress-docker-ansible/\n├── ansible.cfg          # Ansible configuration file\n├── inventory.ini        # Hosts inventory file\n├── playbook.yml         # Main playbook to execute\n├── roles/\n│   ├── docker-host/     \n│   │   ├── tasks/        \n│   │   │   └── main.yml  # Main tasks for Docker and Docker Compose setup\n│   │   ├── templates/    \n│   │   │   └── docker-compose.yml.j2  # Docker Compose template for WordPress, MySQL, and phpMyAdmin\n│   │   └── defaults/     \n│   │       └── main.yml  # Default variables for Docker host setup\n\n```\n\n## Prerequisites\n\n### 1. **Ansible**\nEnsure that **Ansible** is installed on your local machine:\n\n```bash\nsudo apt update \u0026\u0026 sudo apt install ansible -y\n```\n\n\n### 1. **Docker \u0026 Docker Compose on Target Host**\nThis playbook installs Docker and Docker Compose if they are not already present on the target server.\n\n### 2. **AWS EC2 Instance (or any other Linux server)**\nThe playbook assumes you are deploying on a Linux server (e.g., Amazon Linux 2, Ubuntu). Ensure that the security group of your instance allows:\n\n- **Port 22 (SSH)**\n- **Port 80 (HTTP)**\n- **Port 8081 (phpMyAdmin)**\n- **Port 8081 (wordpress)**\n\nYou must be able to connect to the server via SSH.\n\n### 3. **SSH Key Configuration**\nAdd your private key path for SSH in the `ansible.cfg` file.\n\n---\n\n## Setup Instructions\n\n### 1. **Clone the Repository:**\n\n```bash\ngit clone https://github.com/your-repo/wordpress-docker-ansible.git\ncd wordpress-docker-ansible\n```\n### 2. Install requirements.txt:\n\n```bash\npip install -r requirements.txt\n```\n### 3. Configure `ansible.cfg` File:\nUpdate the private key path in the `ansible.cfg` file to point to your SSH private key:\n\n```ini\n[defaults]\ninventory = inventory.ini\nremote_user = ec2-user  # Replace with your remote username\nhost_key_checking = False\nprivate_key_file = ~/.ssh/my-aws-key.pem  # Update with your key file path\n```\n\n### Run the Playbook:\nExecute the playbook to deploy WordPress and MySQL with Docker:\n\n```bash\nansible-playbook playbook.yml\n```\n\n## How it Works\n\n### Docker Host Role:\nThe `docker-host` role installs Docker and Docker Compose on the target host. It then sets up the required Docker Compose file for running WordPress, MySQL, and phpMyAdmin containers.\n\n- MySQL Container (db):\nConfigures the MySQL container using environment variables for the database name, user, password, and root password.\nData is persisted using the db_data volume.\n\n- WordPress Container (wordpress):\nLinks to the MySQL container and uses the WORDPRESS_DB_HOST, WORDPRESS_DB_USER, and WORDPRESS_DB_PASSWORD environment variables.\nExposes the WordPress site on port 8000 of the host machine.\n\n- phpMyAdmin Container (phpmyadmin):\nConnects to the MySQL container using the PMA_HOST and MYSQL_ROOT_PASSWORD environment variables.\nAccessible on port 8081 of the host machine for database management.\n---\n\n## Variables\n\n### MySQL Variables (`roles/Docker-host/defaults/main.yml`)\nYou can modify the following variables for MySQL:\n\n```yaml\nmysql_root_password: rootpassword        # Set the MySQL root password\nmysql_database: wordpress                # The database name for WordPress\nmysql_user: wordpress                    # MySQL user for WordPress\nmysql_password: wordpresspassword        # MySQL password for WordPress user\n```\n\n## Access WordPress\nOnce the playbook completes successfully, you can access WordPress by navigating to:\n\n```bash\nWordPress: http://\u003cyour-server-ip\u003e:8000\nphpMyAdmin: http://\u003cyour-server-ip\u003e:8081\n```\n\n## Troubleshooting\n\n- **Docker Not Running:** Make sure Docker is installed and running by checking with `docker --version` or `docker ps`.\n\n- **Permission Errors:** Ensure that your user has the necessary permissions to use Docker. You might need to add your user to the `docker` group:\n\n  ```bash\n  sudo usermod -aG docker $USER ```\n\n- **MySQL Connection Issues:**  If WordPress cannot connect to MySQL, verify that the MySQL container is running and properly linked.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabrar-2510%2Fwordpress-docker-ansible-setup","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fabrar-2510%2Fwordpress-docker-ansible-setup","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabrar-2510%2Fwordpress-docker-ansible-setup/lists"}