Website Deployment to AWS with Ansible
This provides a simple yet realistic task of deploying a basic website to dynamically provisioned AWS infrastructure. We will work with multiple AWS components through Ansible, and also perform basic web server configuration against a host with Ansible.
We will be running the playbook to gather the env parameters
home/ansible/get-environment-details.yml
As soon as we login to EC2 server, we will switch user to ansible
we will run su - ansible
to become the ansible
user with password cloud_user
.
Run the following command:
ansible-playbook /home/ansible/get-environment-details.yml
Now Replace the word
“Placeholder” in the File :”/home/ansible/env_vars.yml” with an S3 Bucket name
- Open
/home/ansible/env_vars.yml
with a text editor. vim /home/ansible/env_vars.yml
Change the value placeholder to a unique S3 Bucket name of your choosing.
Create “/home/ansible/deploy.yml” and Add an Ansible Play that Configures Your EC2 Keypair, EC2 Instance, and S3 Bucket per the Instructions.
Now Use the Provided Variable file “/home/ansible/env_vars.yml” for Required Parameter Configuration
- Create the playbook and edit it such that it resembles the following:
Add Another Play to Configure the New EC2 Instance:
Install the `httpd` Package, Start and Enable the `httpd` Service
Deploy the Provided Template File into “/var/www/html”.
Use “/home/ansible/env_vars.yml” for required parameter configuration values
- Add another play to
/home/ansible/deploy.yml
that resembles the following:
deploy.yml
Run /home/ansible/deploy.yml to Perform the Required Tasks
- Run the following command:
ansible-playbook /home/ansible/deploy.yml
Website Deployed
👋 Join us today !!
If this post was helpful, please click the clap 👏 button below a few times to show your support! ⬇