Description: Here I have explained, How to create EC2 instance using Ansible
Create an IAM user from AWS console
- Open AWS console and navigate to IAM service
Install Require Packages on Ansible Machine
- Once User created successfully install below require things on Ansible machine
# yum install ansible -y
Python
# yum install python python-devel python-pip
Boto [Boto is the python package which provides the interface to AWS] install using pip
# pip install boto
Create Ansible Playbook to Create EC2 instance
- Add localhost in ansible host file for creating the connection to AWS console
[webserver]
localhost
- Create SSH Key for localhost and copy to authorization
# ssh-keygen -t rsa
- Once key file created copy to authorized_keys and paste as follow
- Create a playbook for EC2 instance and paste below content in yaml file
# vi ec2.yaml---- name: Launching the AMS instancehosts: localhosttasks:- name: Launching the AMS instanceec2:key_name: ansibleregion: us-east-1instance_type: t2.microimage: ami-0c582118883b46f4fgroup: Ansiblecount: 2aws_access_key: WODAJGU3OHZ7RDKG4TPQaws_secret_key: OD3I2mgh/ynyrJJ9Y/bLQto6JLII3gyGBFYJ+w7
Description of Playbook
key_name: Key created in EC2 instance
region: The region on which you want to create new instance
instance_type : Instance Type in EC2
image: Image you want to use to create new instance, You can get image id from EC2 launch console
group: Security Group name which you want to place for VM
count : Number of EC2 instance which you want to create
group: Security Group name which you want to place for VM
count : Number of EC2 instance which you want to create
aws_access_key: Access key from the user IAM user which we have created on beginning
aws_secret_key: Secret key from the IAM user
# ansible-playbook ec2.yaml
aws_secret_key: Secret key from the IAM user
- You will get both the keys from AWS IAM console
- Test playbook content using below command
- Once result showing OK you can run playbook using the ansible-playbook command
Awesome post...
ReplyDeleteThanks for the interesting post, keep continue your good job.
ReplyDeleteDevOps Full Course Tutorial for Free, DevOps Tutorial for Beginners
Kubernetes Full Course Tutorial for Free, Kubernetes Tutorial for Beginners
Ansible Full Course Tutorial for Free, Ansible Tutorial for Beginners
Docker Full Course Tutorial for Free, Docker Tutorial for Beginners
Openstack Full Course Tutorial for Free, Openstack Tutorial for Beginners
Learnitguide.net
Thanks for the interesting post, keep continue your good job.
ReplyDeleteHow to Install Docker on Ubuntu 20.04 Easily
Thanks for the your useful post, its really helpful for others. Continue your good work.
ReplyDeleteWhat is Rest API? Rest API Explained with Examples | Rest API Tutorial for Beginners
Thanks for the your useful post, its really helpful for others. Keep Continue your good work. We will support you.
ReplyDeleteLinux for DevOps Full Course for Free
Ant Full Course for Free
Maven Full Course for Free
Chef Full Course for Free
Ansible Full Course for Free
Git Full Course for Free
Docker Full Course for Free
Jenkins Full Course for Free
Thanks for the interesting article, It really helped to me and others like me. keep continue your good work.. Also try these kind of topics, that will help everybody.....
ReplyDeleteWhat is Machine Learning? Everything You Must Know
Ansible Jinja2 Templates Explained with Examples
Steps to Configure Centralize Container Logs Using ELK Stack
Deploy Serverless Application using Ansible Easily
Deploy Serverless Application using Terraform Easily
Automate Database Backup using Ansible Easily
Host Static Websites on AWS S3 Bucket Easily
Generate Signed URL using AWS CloudFront for S3 objects
How to Install Podman On Ubuntu? Create Containers
How to Recover Deleted Files from AWS EC2 Easily?
Recover SSH Public Key from Private Key Easily
How to Migrate AWS EC2 to AWS EKS Easily? Migration Plan
How to Create Own ChatBot on Ubuntu using Python Easily
Create AWS EKS Cluster using Terraform Easily
Create AWS EKS Fargate Cluster using Terraform Easily
How to Setup SSH Tunneling To Access AWS EC2 Easily
How to Install Discord Server on Ubuntu Easily?
Thanks for the interesting article, It really helped to me and others like me. keep continue your good work.. Also try these kind of topics, that will help everybody.....
ReplyDeleteHow to Move AWS EC2 from One Region to Another Region
How to Migrate Vmware VM to AWS EC2 Easily
Top 10 Useful Kubernetes Commands with Examples
How to Learn Machine Learning - Comprehensive Guide
Create your Own ChatGPT using Python on Ubuntu Easily
Top 10 Use Cases of ChatGPT - Everybody Must Know
What is ChatGPT? - ChatGPT Explained
The Future of Kubernetes and Docker
Orchestrating Docker Containers with Kubernetes
Scaling Docker Applications with Kubernetes
Kubernetes vs Docker Understanding the Differences
Best Practices Docker Containers in a Kubernetes Cluster
Kubernetes and Docker Perfect Pair for Container Management
Getting Started with Kubernetes and Docker