This repository implements the deployment of the application devops-sample-django-app using Ansible.
- Install Python 3.8
- Install required libraries
- Install Vagrant
-
Open the project:
cd exercise-06 -
Create and activate a virtual environment:
python3.8 -m venv venv source venv/bin/activate -
Install dependencies:
pip3 install -r requirements.txt
ansible-galaxy install -r requirements.yml -p roles/vendor
-
Start the Vagrant VM:
vagrant up
-
Run the Ansible playbook:
ansible-playbook -i environments/dev/inventory.yml site.yml
-
Check connection on ports 5432 and 5000:
nc -zv 192.168.56.11 5432 nc -zv 192.168.56.11 5000
-
Verify PostgreSQL version:
vagrant ssh -c "pg_config --version" -
Perform a POST request:
curl -i -X POST -d '{ "username": "user123", "email": "user@example.com", "password_hash": "example" }' -H "Content-Type: application/json" http://192.168.56.11:5000/api/user
-
Perform a GET request:
curl -i -X GET http://192.168.56.11:5000/api/user
-
Restart the VM:
vagrant ssh -c "sudo reboot" -
Verify the application is still running:
curl -i -X GET http://192.168.56.11:5000/api/user