Create EC2 instance using Ansible - Part 1

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] hello this video is on cloud automation with ansible and today we are going to see how to launch an ec2 instance in AWS using ansible we will discuss two scenarios over here the scenario one handsome and Sybil will be anyone your system locally and in scenario 2 and civil will be running only ec2 bastion house so let's start with scenario 1 for this we will need a Linux server hosted locally on your PC Here I am using a center 7 with modules such as butoh Python and ansible installed you will also need a AWS account with privileged access to launch ec2 instance so let's start with creating the AWS account log in to your AWS console go to item section users and then add user enter username select programmatic access since we are going to use this user to access a device programmatically then you can attach policy or you can create a new policy we are going to use an data attached an existing policy easy to Fluxus create user then you can download your secret access key and access key ID once downloaded you can log into a server now we'll install ansible now since this is a Linux server Python will be pre-installed over here but for installing both o we will no need pip a Python module to be installed so we need to install that and smell its installed we can check it like and so will - - version so the version which we are using is 2 dot v dot v and the config file will be HC and sibilance sibilance CMZ now let's install the pip module the PIP is installed we can go ahead and install boto pip install photo [Music] the Buddha is installed now no you create a dot both of I locally in your home directory with these details and enter the access key ID and secret secret access key which you just downloaded for the user over here and save this file with permission for zero zero I am done with mine once you are done with yours let's proceed with writing the PlayBook task taught by ml is my playbook provide a name to the PlayBook city launches for me provide host localhost and then connection should be local knowledge start with tasks the module which we're gonna use to launch ec2 is easy - you can find the module in the ansible Daksh accent okay and you can find a lot of examples over there let's proceed with writing our playbook now you have to define the instance type which we are gonna launch just since I am using free tier so I will be launching t2 that micro next is key key pair so key pair you will be finding in the ec2 section if you have an existing key pair use that one if you don't have any then go and launch so I have one I'm gonna use it [Music] takes to find the image that is am I so again am i you can find by launching an instant since I'm gonna use Amazon am I will be using this in my ID you can find other a my ID is also in the EMI section now define the region I'm gonna launch my instance in the US list too and the security group I'm gonna use default security group for me then the number of instances to be announced it's just one for me subnet ID is the V PC subnet ID so you have to choose a subnet from the region we're gonna launch your instance go to V PC and in the subnet section you can find all the subnets which are available for you select one which you which is the new reason so for me I am going to use this one then if we want the playbook to wait for the instant to be launched liberators yes and then provide a sign public IP which means if you want your ec2 instance to be assigned a public IP by default to give it as yes if you want it to think we are done save the playbook now before running the playbook let's check if we have an existing ec2 instance running so I don't have any let's go ahead and run the playbook so it's running failed it looks like I have given the wrong subnet ID so it validates with your AWS configuration and if something is wrong it fails let's go ahead and check the subnet ID again to see them turn it again but they're always defined gathering facts as know it's it has logged into my AWS console and it just trying to learn the instance now shake however running is just now okay so the playbook has completed successfully you can run your own playbook you can launch your own instance and once again don't forget to remove the instance for more videos or an automation btran scible please subscribe my channel and please watch this section for the next video which is on scenario 2 for launching ec2 instances from ec2 Bastion thank you
Info
Channel: RedGeek
Views: 24,088
Rating: 4.8713827 out of 5
Keywords: aws, ec2, ansible, automation
Id: gEX1HbM4KSM
Channel Id: undefined
Length: 9min 52sec (592 seconds)
Published: Sun Jul 01 2018
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.