- Overview
- Tech Stack
- Architecture
- Prerequisites
- Usage
- Sample Runs
- Project Highlights
- Contributing
- Issues
- License
This is a simple Ansible playbook to provision an EC2 instance on AWS, setup a wordpress site, and create a MySQL database.
- Ansible
- AWS
-
Install Ansible
$ ansible --version ansible [core 2.16.6] config file = None configured module search path = ['/home/saeed/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules'] ansible python module location = /home/saeed/.local/lib/python3.10/site-packages/ansible ansible collection location = /home/saeed/.ansible/collections:/usr/share/ansible/collections executable location = /home/saeed/.local/bin/ansible python version = 3.10.12 (main, Nov 6 2024, 20:22:13) [GCC 11.4.0] (/usr/bin/python3) jinja version = 3.1.4 libyaml = True
-
amazon.aws ansible collection
$ ansible-galaxy collection list amazon.aws # /home/saeed/.local/lib/python3.10/site-packages/ansible_collections Collection Version ---------- ------- amazon.aws 7.5.0
-
community.mysql collection
$ ansible-galaxy collection list community.mysql # /home/saeed/.local/lib/python3.10/site-packages/ansible_collections Collection Version --------------- ------- community.mysql 3.9.0
-
Define the aws credentials at the
vars.yml
file:access_key: <AWS-ACCESS-KEY-ID> secret_key: <AWS-SECRET-ACCESS-KEY>
Make sure to modify the path to your private key file required for EC2 machine ssh.
-
Create the whole infrastructure
ansible-playbook wordpress.yml -e "@vars.yml" -e ansible_python_interpreter=python3 -e ansible_host_key_checking=false --private-key=/home/saeed/.ssh/saeed_aws.pem
-
Stop the EC2 instance
ansible-playbook stop_ec2.yml -e "@vars.yml" -e ansible_python_interpreter=python3
-
Start the EC2 instance
ansible-playbook start_ec2.yml -e "@vars.yml" -e ansible_python_interpreter=python3
-
Delete the EC2 instance
ansible-playbook delete_ec2.yml -e "@vars.yml" -e ansible_python_interpreter=python3
- Modularity: Uses Ansible Roles for flexible configuration.
- Persistence: Employs MySQL database for data durability.
- Speed: Create the whole infrastructure with one command.
Contributions are welcome! To contribute:
- Fork the repository.
- Create a feature branch:
git checkout -b feature-branch-name
- Commit your changes:
git commit -m "Add a new feature"
- Push to your fork and submit a pull request.
If you encounter any problems, please create an issue.
This project is licensed under the MIT License. See the LICENSE file for details.