This DevOps project aims to automate the deployment process of a Python-Django web application using a combination of tools and technologies such as AWS, Terraform, Jenkins, Ansible, Apache Tomcat, Git/GitHub, etc.
This section provides step-by-step instructions on how to set up the development environment, configure individual servers, and create a Jenkins pipeline for automated builds and deployments.
- Create a GitHub repository for the application.
- Open VScode and clone the application repository.
- OPTIONAL: If using a web app from GitHub, download it to your local machine.
- In VScode, open the cloned repository folder and add the application data.
- Commit and push the changes to GitHub.
- Install and configure Terraform.
- Create a
main.tf
file and paste the Terraform configuration. - Run
terraform init
to initialize the project. - Run
terraform apply -auto-approve -input=false
to apply the infrastructure changes. - Verify user_data installations by checking
/var/log/cloud-init-output.log
.
- Generate a Personal Access Token in GitHub.
- Replace
<personal_access_token>
with the generated token.
- Clone the repository using the access token.
- Commit and push the changes.
- Set up SSH key configurations for Jenkins and Ansible Servers.
- Copy the initialAdminPassword for Jenkins login.
- Access Jenkins on
http://<EC2-Public-IP>:8080
. - Install suggested plugins and additional plugins, including "Publish over SSH."
- Configure Jenkins credentials.
- Set up GitHub webhook for the repository.
- Configure SSH settings for the Ansible Server.
- Create a directory to store data from the Jenkins Server.
- Create an Ansible playbook.
- Create a Jenkins Job as a Pipeline.
- Enable "GitHub hook trigger for GITScm polling."
- Choose "Pipeline Script from SCM" and specify the Repository URL.
- Add Jenkins credentials for the Jenkins Server (SSH username and private key).
- Specify
*/main
as the Branch Specifier.
- Login to the Developer Server.
- Navigate to the
Web-Application-Repository
folder. - Create or edit the
Jenkinsfile
with the desired configuration. - Commit and push the changes to the GitHub repository.
- Login to the Ansible Server.
- Navigate to the
/home/ec2-user/ansible-data/ansible-playbooks
directory. - Create or edit the
deploy-web-app.yml
playbook with the desired configuration.
- Run the Jenkins Job to trigger the pipeline and deploy the web application.
- Access the Web Server's IP on port 8080 to interact with the deployed application.