→Pre-requisites:
— >RedHat Ansible downloaded and configured in the local system.
Do check out my previous article for Ansible👇👇:
♦️ Deploy Web Server on AWS through ANSIBLE!
🔹 Provision EC2 instance through ansible.
🔹 Retrieve the IP Address of instance using the dynamic inventory concept.
🔹 Configure the webserver through ansible!
pip3 install boto3 //assuming python3 is installed
Encrypted Vault🔒
- hosts: localhost
vars_files:
- secret.yml
tasks:
- name: Provision os in AWS
ec2:
key_name: "keytask" //keypair to be attached to the instance
instance_type: "t2.micro"
image: "ami-0ebc1ac48dfd14136" //amazon linux
count: 1
wait: yes
vpc_subnet_id: "subnet-e7780dab"
region: "ap-south-1" //asia-pecific-south region of AWS
state: present
assign_public_ip: yes
group_id: "sg-0512d293cfb4af6e4" //security group
aws_access_key: "{{ myuser }}"
aws_secret_key: "{{ mypass }}"
register: ec2
- debug:
var: ec2.instances[0].public_ip
#aws #ansible #linux #web-server #dynamic-inventory