Website Deployment to AWS with Ansible

Kubernetes Advocate
AVM Consulting Blog
2 min readJun 10, 2020
Thanks for source karneliuk.com

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:
env_vars.yaml

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

Thanks for source Sysadmin Casts

👋 Join us today !!

️Follow us on LinkedIn, Twitter, Facebook, and Instagram

If this post was helpful, please click the clap 👏 button below a few times to show your support! ⬇

--

--

AVM Consulting Blog
AVM Consulting Blog

Published in AVM Consulting Blog

AVM Consulting — Clear strategy for your cloud

Kubernetes Advocate
Kubernetes Advocate

Written by Kubernetes Advocate

Vineet Sharma-Founder and CEO of Kubernetes Advocate Tech author, cloud-native architect, and startup advisor.https://in.linkedin.com/in/vineet-sharma-0164

Responses (1)