Deploy Web Server On AWS Through Ansible

ansible-vault create --vault-id Abhi@prompt secret.yml
- hosts: "localhost"
vars_files:
- secret.yml
tasks:
- name: "ANSIBLE_AWS_EC2"
ec2:
key_name: "Abhinav"
instance_type: "t2.micro"
image: "ami-0ebc1ac48dfd14136"
wait: yes
count: 1
instance_tags:
Name: EC2_BY_ANSIBLE
vpc_subnet_id: "subnet-3e0b1456"
assign_public_ip: yes
region: "ap-south-1"
state: present
group_id: "sg-452b0f3c"
aws_access_key: "{{access_Key}}"
aws_secret_key: "{{secret_Key}}"
register: Abhi
- debug:
var: Abhi.instances[0].private_ip
register: IP_Var
- debug:
var: IP_Var["Abhi.instances[0].private_ip"]
ansible-palybook --vault-id Abhi@prompt Aws.yml

👉🏼Step-4

- hosts: all
tasks:
- name: httpd ec2
command: "sudo yum install httpd -y"
- name: start service
service:
name: "httpd"
state: started
enabled: yes
- name: copy files
copy:
src: "/etc/ansible/Task_1/abhinav.html"
dest: "/var/www/html/"
ansible-playbook web.yml

--

--

--

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Localhost Academy Scholarship

Scrum Values — Food for thought

My first Solidity smart contract on ParaState platform

compile

Development Report #09

Best mobile app backend ?

How To Import and Visualize Stock Market Data Using Python

png

AWS Serverless Application Model for ASP.Net Core Apps

Things to consider when designing objects

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Abhinav shukla

Abhinav shukla

More from Medium

TryHackMe Startup Walkthrough

Installing Apache Web Server on CentOS8.

Owasp Dependency Check Slack Notification in Jenkins pipeline

Configuring Apache webserver and Haproxy using ansible Roles on AWS.