Posts

Showing posts from August, 2020

Create AWS EC2 instance with webserver installed using Ansible

Image
Hello all, in this blog we are going to learn how to provision/create/spawn an AWS EC2 instance using Ansible tool. We will make all the steps automatic so that our ec2 instance will be created and a webServer starts running without any manual intervention. We will write two ansible roles: One for creating aws ec2 instances with desired ingress port opening Another for installing and configuring apache webserver Go to ansible default role path . cd /etc/ansible/roles and create two ansible roles using below commands ansible-galaxy init ec2_instance ansible-galaxy init custom_webserver Paste the below content in ec2_instance/tasks/main.yml --- # tasks file for ec2_instance ######################################################## ##### Below file is required to login aws account ####### - include_vars: secure.yml ##################################################### ###### Creating a security group for ec2 instance ### - name: create a security group ec2_group: name: