Ansible Playbook to Create EC2 Instance

We will learn to Ansible Playbook to Create EC2 Instance but my this Article also Creating the EC2 Instance. Now this Article is different because We don't save the Credential in Ansible Machine for Security.

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

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

Verity the packages :-

3. Create a IAM Role to Ansible EC2 Instance and Add :-

4. Attach Role to Ansible EC2 Instance :-

5. 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
  - name: launing 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

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.

Ansible Playbook to Create EC2 Instance Ansible Playbook to Create EC2 Instance Reviewed by Unknown on September 02, 2018 Rating: 5

No comments:

Powered by Blogger.

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!