how to launch aws instance using ansible


We will learn today how to launch AWS EC2 Instance using Ansible.
Today, Automation time So Every want to saving  time and we will use ansible for automation to create instances in AWS Cloud Service.

1. Create a EC2 Instance first by AWS Console :-
2. Install Same Packages in Ansible Machine :-
  • Ansible
  • Python
  • Boto
  • Pip
Command Below :-
sudo amazon-linux-extras install ansible2
or
yum install ansible
yum install python-pip
pip install boto

Note :- If first command not running then using this command.
pip install ansible

Verity the packages :-






3. Create a IAM and Save the Access Key and Secret Key :-


Note :- I am not sharing Secret Key in Above Screenshot for Security Purpose but you save your keys in your machine.
vim .boto



 
4. Create a Ansible file for Creating EC2 Instance :-
vim ec2_create.yml

Past below code in this ec2_create.yml
- name: ec2 instance
  hosts: localhost
  connection: local
  tasks:
  - name: launing ec2
    ec2:
      instance_type: t2.micro
      key_name: ss
      image: ami-00b6a8a2bd28daf19
      region: ap-south-1
      group: test
      count: 1
      vpc_subnet_id: subnet-fcc87eb0
      wait: yes
      assign_public_ip: yes


5. Run the Ansible Playbook :-
ansible-playbook ec2_create.yml


Now, You can see in AWS Console New EC2 Instance is running.

Note :- We don't define the Volume in Ansible Playbook it will take Automatic 8 GB Volume.
If you want to more details in ansible playbook use this link.



how to launch aws instance using ansible how to launch aws instance using ansible Reviewed by Unknown on September 01, 2018 Rating: 5

No comments:

Scribe

http://feeds.feedburner.com/LinuxAndAws
Powered by Blogger.
X

Get Updates On

Linux Tutorial

AWS Tutorial

Devops Tutorial

We are going to send you our resources for free. To collect your copy at first, join our mailing list. So don't miss any updates, stay connected!