Simple DevOps Project-2 | CI/CD pipeline using GIT, Jenkins & Ansible

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello everyone welcome back to Biloxi technologies my name is Shankar I'm a AWS under DevOps instructor over here in this video we are going to see DevOps see ACD pipeline setup we have already seen the similar kind of video previously that is simple see a serie pipeline setup for DevOps what we are going to do in this video is to addition to that we are going to introduce ansible as a deployment tool over here in our previous video we have seen how to set up the Jenkins and Tomcat server under deploying our wire file by using the Jenkins yourself I mean to say build under deploy in this video build will happen in Jenkins and apply can happen through the and simple way because you we cannot able to do the deployment in some of the complex environments that's why we should go to the sum of the external deployment tools if we recap what we have done in our previous lab our previous video is let me go back to that this is what we have done in our previous video if you haven't followed our previous video or you are watching this video first time please go through with that video complete the clap and come back here because this video is continued continuation for our previous video I am assuming that the previous infrastructure is the available on top of that one I am going to add the today's infrastructure so this is what we have done in our previous lab our previous video where Tolliver's has checked in their quadrant to get Jenkins is going to take that code build and then deep-lying going to deploy it into an two tomcat server but in today's video we are introducing ansible where developers checking their code on to get Jenkins will take and build that code whatever build artifacts we got it will give it to the ansible ansible is going to deploy it into the Tomcat server we are assuming that Tomcat is running on a VM for this we need to follow these steps as I said the lab setup was created for the simple DevOps project for CAC D should be available and you should follow the how to install and configure the ansible which is already available in our channel I have already set up my ansible server what we are going to do in this video is we are going to enable password Lai's authentication in between ansible to tomcat server this is one step we are going to do I will create a user called ans admin on the ansible server as well as the Tomcat server because we are going to deploy on Tomcat server through ansible so password list authentication must be available and we are going to use install publish over SSH plug-in on Jenkins and also we need to configure it I hope you are already aware how to install plugins and configure it and there we have to write yet simple Amal playbook to dip lie the jar where file onto the target system again this playbook has is going to be initiated by the Jenkins itself so everything will be triggered by the Jenkins but the tasks will be running on the different different systems that is how the real-time infrastructure configured once we have installed publish our association and our play books are available we are going to modify the existing job which I created in the previous video same job I'm going to modify according to the current infrastructure once we have done that one we are just going to trigger the job it should initiate and the deployment should happen and if we change the code also the after changing the code again if we trigger a job it should get deep the latest coat hope you have you you are you you understood what we are going to do with that let's go and do it I'm just jumping into my AWS console right now this is my AWS console where I have three servers that is Jenkins server Tomcat server and ansible server I'm just going to log into my drink in server this is my Jenkins server and this is the dashboard where we have two jobs this is what I was talking this is my previous job I haven't changed anything and just to show you the configuration of this job it is going to pull the core from the hello world get this is my repository which is there in the Ville AXI tech once it is pulled from the master branch it is going to create the package once packet package is created it is going to deploy into the target system but here I am NOT going to deploy through the Jenkins job I am going to deploy through the ansible so I am going to remove this and add additional steps anyway let it be and this is the code where we are having we need to modify if we modify it will get deployed right into that our Tomcat and our jinking jinking server is running on a zero eight zero and if this is the our tomcat server the IP address 199 ends with 199 if you see this is the tomcat server so Tomcats are were currently up and running and the code whatever is deployed is latest code whatever is there in our in our git server and we have one more server that is ansible server this is what i have set it up already if you don't know please follow the video which is blinking lights head corner of this video right now you can go and set it up enter stop so I am just logging into ansible because we we have to complete one first step that is enable the create a user and enable the password less authentication in between the and bill server earned Tomcat server so first I'm logging into my ansible system once logged in I am creating a user called NS admin directories exists because I tested it with the same user that's ok and VA pseudo because he needs the root access safe to G I insert mode ans admin and it should be no password because with this user we are going to run the playbooks so while running it should not prompt for password so I have created user and added him to the added him to the pseudo spell similar way we need to create the user on the Tomcat server also because through the ansible we are going to deploy on the Tomcat server so I'm using my key ec2 - user I have enabled password-based authentication if you observe password-based authentication also so user add a NS admin here also it may say that yep and VA sudo shift G insert more illness admin ok we have created a user and added into the sudo swear one thing I forgot that is setting up the password I have set up the password on the Jing this is Tomcat server ok 75 and this is 60 80 sensible system so pas SWT am a sod moon I have set up the password as well now what we need to do is we need to enable the password less authentication in between these two systems for that I am shifting as ans admin and what I will do is I am going to generate the key SH - key gen okay it's generated okay overwrite because earlier we have generated yes I want to overwrite okay it has been created now copy this key into the target system yes Shh copy - ID on to our top target system this is our target system so here I'm going to copy it okay it has been added let me try it whether I can able to log in now without password yes I can able took and let me execute one of the test playbook the and symbol all - sorry IP address okay before that - lets go and add this IP address onto our hosts file va slash it easy and simple horse oh it is already there no need to add under the group name is web service that's fine Oh read-only access this file now anus and Sybil all - impinge just testing whether communication is enabled or not it is successful so the ansible master - and simple client the communication is enabled so if I open again our PPT the first step is working for an enable password less authentic Asian next thing is install publish over SSH plug-in on the Jenkins let's login to Jenkins now yeah this is Jenkins I'm going to install plugin the plug-in name is publish over SSH go to available search for publish over that's it installed oh I have installed it should get restarted okay let me quickly restart it until it comes up why I have restarted is I was testing it before so that's why if the definitions were not clear anyway meantime what we will do is we'll move to next step that is a right here playbook to copy grr warfare so I have written already written me a simple ansible playbook that is under CD / opt under opt we have playbooks directory under playbooks directory we have a file called copy file dot yml in this we have your definitions that is any ml file starts with 3 minuses under next the target systems nothing but hosts on which systems does it act we might have seen all or a group of servers so web servers is a group which we have created under the hosts file if you see web servers so what I am trying to say is please play this playbook on web servers group under web servers group we have one server it may be ten servers or hundred servers on all those systems this playbook can play next become true means execute all these instructions has a root user okay execute all these instructions as a root user next what are the instructions should I need to execute this that will be there under tasks section this is the task section under tasks section I am using a module called copy for copy we should have the source under destination source nothing but where is your source for destination nothing but where is your destination where so what I am going to do to work these play bookings I will copy the ver file on to this location I will copy ver file on to this location in the ansible server source nothing but ansible server location this is ansible server location if you see if I go to CD you can see there is already where file which was created some time back ok and date if I see it is created under 1536 nothing but here our I go anyway will execute you a new job new eggs job is going to replace this char where faith so this way our file we are going to copy an to target system on to this location target system nothing but this server this server is Tomcat server on to Tomcat server into this location it will get copy once it is available in this location the code whatever is there in this bar file under this location that code will be visible over here that code will be visible over here ok that is how it works that is that is the playbook which I have already written and it is available I am going to just approve or execute this playbook through the Jenkins I don't want to execute from the ansible server Jenkins is going to trigger this ansible playbook ok because Jen Jenkins is a centralized system kind of thing I'm logging in to Jenkins because my previous definitions were not cleared that's why I have quickly rebooted our restarted our Jenkins application now again go to manage Jenkins manage plugins available this time it should be available publish over SSH you can see here this is not installed enough earlier it was installed under definition I deleted it but even the definitions were not deleted properly now I am installing publish over SSH once the installation is done you need to configure it configure nothing but by using publish over SSH what do you do and are on which service you are going to use this one so our purpose of installing publish over SSH is we want to execute some playbooks on to the target system nothing but from Jenkins server I want to execute ansible playbooks so this plug-in I need to use for ansible so configurations manage Jenkins go to system configuration here you need to specify the target systems nothing but we are giving access to our Jenkins system to do some activities on the target system nothing but in this case I am giving you access to my Jenkins to execute some playbooks on my ansible server for that you can use the key based authentication which is not a right way to do because if you specific you over here it made somebody may take it and misuse it so it is not good way that's why I am going to do this SSH servers with to the password-based authentication in our case the server name I'm just giving for it is like a reference and Sibyl and sibyl's server and the host name I don't want to I don't have host name I have IP address so I'm giving the private IP address because these all are internal in the same VPC are subnet so it can communicate internally so there won't be any issue if you use the private IP address and they use the name NS admit this is what we have created for ansible and the to execute on the target systems also and we should provide the password also by default it won't prompt for password in the advanced rejection if you see there is the option use the password based authentication choose this option if you choose it will ask you the password I how clear in the ans admin password once you have specified the password you can test the connection nothing but now you were jinking server we will try to connect to the system and with this username and password and we just execute some ping test or test command it should work if it working nothing but communication is established successfully whatever information you have provided everything is correct if it is not working there is some problem ok so the configuration is completed successfully so if I open again our PPT we have enabled a password less authentication if you start to publish over SSH on the Jenkins and configure written playbook for the jarowair file copied ok this playbook we need to modify according to where our jar file is going to get copied in my case I have already I have already decided to copy my jar file on to which location already on to this location already on to this location so that's why I don't want to change if you are copying your file into some other location apart from this you need to specify that path over here right let's go again back to our yeah so now go back to Jenkins now I am going to modify the existing job this is our previous job and configure under configure I'm going to remove this one this is not needed so now what it will do it will only take the code and build it once the build is happened what our artifacts will come it will sit in the Jenkins itself but I want to copy those on to the ansible system then only ansible can copy unto the his client systems so it is like indirect way but there are some advantages which we are going to see in the later classes oh sorry I forgot to explain in the ad post build session once the building is completed what should we need to do once the build is successful successful then send files our execute command over SSH this will be available if you configure the publish over SSH plug-in appropriately choose this option now SSH server nothing but excuse me what is the target system we have only one target system which is ansible server which we created and source nothing but where is your source file nothing but where file usually where file under current or directory there is a web app web app target okay this is the location it will be available star dot where star dot we are nothing but the name might be anything which ends with dot where so this is the target location let me check it out I just copied yeah so this is the location next one would be the remoter directory on to the target system where do you want to copy on to target system I want to copy on to /opt slash playbooks why I am giving this location this should be double because it cannot identify the special character that's where double slash you need to give why I am giving this location the where file whatever is there it will get copied into this location entire way nothing but /opt playbooks slash web app slash targets last ah dot star dot sorry star dot we're like this it will get created that's why in my playbook I have given the total path /opt playbooks it will create a web app target not create it should be a exists then it will create a web app dot we are okay our where file name is web app we have given key instead of star you can give the web app also but this is best practice next execution command I don't give because immediately you should not give next to command what command we need to execute that is once the target file it is copied nothing but into the ansible it will be available under this location now I want to execute this playbook to execute display book you need to give the full path nothing but where is your file is located this copy file dot yml is are sitting under /opt playbooks then the command would would be ansible playbook /opt playbooks copy file dot yml this is the command you need to execute but don't do the two different tasks into your single single task because it is not advisable it may not work also so I am creating one more publish over associate that should happen on the ansible an ansible server execute this command that is what I am doing now apply save it right I have applied save now if I execute or if I build this job what should happen now nude web app dot VAR file will get created that will be copied into the ansible system and spool system got disconnected I am relocking into ansible so into ansible system which location does it get copied say opt playbooks so it is going to get copied into the it is going to get copied into this location okay why this location in the job itself it is there we are copying so let me go inside to this and adjuster once the job is executed its timestamp should get changed similar way it will happen further it will happen further sorry our this is okay this is our Tomcat server so it should happen to Tomcat server also in Tomcat server which location does it get copied again in the playbook itself it is there so in this location it will get copied let me go to in this location LS minus L okay this is the where it is going to get carpet you can see the timestamp it is some time back it get copied now let me execute the job if you were able to understand the previous video properly this might not be a big issue for you okay anyway don't worry if you have any doubts you can write it in the comments so that I'm going to reply for your our doubts so I am running this job once the job is successfully completed you can see a less - yell still yeah now you can see here it has been replaced with the current date because it has been replaced and code is not changed so you cannot see the difference your timestamp also changed now if you see this work the code is safe right and if I go to my Jenkins job it should be success if you see here the output you can see ok initially build is successful till here you know next one is connecting to the host it is connected under transferred here file nothing but it is copied here file then playing playing nothing but it is executing this playbook which PlayBook opt playbooks copy file dot yml it is copied and it changed one unreachable failed nothing right now what I will do is we are going to change the code we are going to change the code again we will execute this job this time we can see the latest court get reply just edit it DPL why deployment is happening deployment is going to happen through through what through ansible latest code updated project to example this is a project to assuming that this is project to to so I have updated new code ok I didn't enable policy iam that's why I'm going to run this job manually again ok if you don't want to do that one you can go under enable the policy M depending upon your time now again I'm executing this time I could able to see the latest one whatever we have given so before we are going to do that one I will just to show you here also now this is not yet updated first ansible will get updated then Tomcats our work get update get updated yeah you can see here latest code has been updated nothing but wire file here also latest code has been deployed now let me refresh this page latest code has been the latest code is available right quite interesting right so this is how we can use the ansible as a deployment tool also not only configuration management - edition this one we can do one more thing what we can do is you can have only plain system target system if you see these Tomcat server I have already installed the Tomcat instead of taking the already installed a tomcat server you can take a plain system and right here playbook which can install Tomcat on the server whenever you execute this playbook then what you can do is you can add one more rule here nothing but one more job here under configuration SSH before what I can say in this before executing this playbook you can add one more SSH server on to the Tomcat server execute sorry execute one more playbook from the ansible itself that you can do or you can take it as an assignment under do it I'm not going to do the task because I am moving to next level that is where I am going to deploy this time with the Tomcat and this way our file together any darker container okay in next video I am going to deep lie the this ver file on the Tomcat - docker container I don't take anything it should create your docker container whenever I exit nothing but first we need to write here the ocker file from the docker file it should create your docker image darker image through it is going to create your docker container right hope this video helps you and please practice if you were able to successfully complete this laughs means you are in a good situation to answer most of the questions in the interview right hope you enjoyed this session and I will see you in the next session thank you and if you liked this video please subscribe to our youtube channel and also share with your friends if it is if you field that it is useful okay thank you and see you in next video
Info
Channel: Valaxy Technologies
Views: 199,023
Rating: 4.9208522 out of 5
Keywords: aws, amazon web services, Certified Solution Architect Associate, certification, beginners, administration, Guide, tutorial, training, fundamentals, devops, devops realtime project, devops project, ansible deployment, jenkins test job, ci/cd, pipeline, project with git jenkins and ansible, docker, kubernetes, ci/cd pipeline, ci/cd project, valaxy devops, devops training, devops realtime training, devops project from scrach, mini devops project, mini
Id: nE4b9mW2ym0
Channel Id: undefined
Length: 30min 54sec (1854 seconds)
Published: Thu Aug 23 2018
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.