CI/CD with Ansible Tower and Github

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments

This is actually really cool!

I'm wondering is this is possible with open-source alternatives (AWX, Gitlab).

👍︎︎ 4 👤︎︎ u/alainlehoof 📅︎︎ Jun 25 2019 🗫︎ replies
Captions
hi welcome to this video presentation and demonstration on CI CD with ansible tower and github my name is keith Tenzer i've got twenty plus years of experience as an operator developer architect and inventor I have a blog at Keith's Tenzer comm and have been a reddit since 2015 as a principal solutions architect now you might be thinking see ICD no Jenkins you must be crazy you're insane I don't want to even listen anymore to what you're gonna say because it's just gonna be garbage I assure you it's not and the point here is not to say we don't need Jenkins but to look at potentially a much simpler workflow involving ansible tower which is a platform for ansible puts an api and lots of our back and lots of capabilities in front of ansible and basically connecting into github and so that's what we're going to be doing in this case we're retiring our dear old Butler Jenkins who's obviously served as well for so many years but may no longer be needed so let's check it out and see what it looks like a world without Jenkins first the solution architecture to give an idea of a big picture here on the Left we have a developer and I'm gonna in the demo go through this workflow he's going to check out a future branch make code change and do a pull request to github that's gonna trigger a web hook to ansible tower which then spawns basically a workflow a workflow and ansible tower is just a series of job templates which and each job template is basically a playbook and each playbook of course consists of a series of tasks that we're performing in this case we have four different kinds of job templates or playbooks start four different get four different types and and they're divided into two different groups so we have the ones in red which are owned by operations or infrastructure and the one in blue which is owned by DevOps so already we see that tower really brings these worlds together Jenkins can never do that so infrastructure operations folks never really use Jenkins and here they can do that and in and we can bring these worlds together so that one of the advantages we'll see some others basically the processes we provision our infrastructure we inventory it obviously because we just built it so we need to know IPS and things like that to get to it then we execute the developer playbooks which are going to basically build the application run unit tests and acceptance tests and then clean it up and of course report back to github the status and that pull request that was issued if it was successful or failed or something else and then our lady on the right cheeks can do a code review and potentially merge that code to the master branch so let's take a look at this under the hood the first thing I'm going to go do is ansible tower and show how we've got the setup so inadible tower we've got a couple projects we have our go hello world project is actually where the source code is for a go application it's also though where the play books are to do that third step which is building it and doing acceptance test unit tests though that's being provided by the developers then we have paths and Yaz play books or get up repository with those play books and that's owned by the infrastructure ops guys and they're providing play books to provision infrastructure D provision inventory all that good stuff and the beauty here is that they can use those same play books that they're using for other things potentially other developer groups or even people that are just you know need to consume you know IT services easily and dynamically so there's a huge degree of reasonability that we would never even get close to with with with Jenkins so that's a really a really beautiful thing in my opinion and this all comes together then so we're pulling play books from both of these repositories and templates so we create job templates in this case to provision a fedora remove it do our go build and we bring that together in what like what I referred to before is a workflow so what we're triggering is this go CI CD workflow which basically maps to our in our solutions architecture those four kind of steps or pillars we provision in this case fedora we do an inventory in this case on the development environment we do our go build acceptance test and then we clean it all up and report back to github so from get up what we're executing is basically this this this this workflow we're full here if I go now into into github I can actually see this go I'll go hello world application you can see the source code here it's under source hello under ansible though I have basically my playbook and a role for doing this go build again provided by the developers so it's isolated and they're providing that as well as I've configured the web hook as you can see so any time code is pushed into this repository it's going to trigger web hook and send information a payload to ansible tower you can see 46 for to a 72 for 8 which is same IP here that's no coincidence that's that's tower so it's sending the web hook there where it's gonna kick off that workflow that I just showed you so let's put on our developer hat and and give this give this a go so I'm gonna look at git branch I'm on my local desktop now you can see I'm working in a big branch called patch one I'm gonna go to my IDE here and I'm just gonna introduce some broken something that's gonna break the build basically so I'm creating a syntax error here obviously the ID even Flags it and knows that that's not something that we should have there I can now see that this file was in fact modified I can commit it locally just call it broken code give it a commit message and then I can push to my github repository as the feature branch so I'm pushing this code into that future branch so off it goes it just did that and did the push now if I go back to tower I can go to my jobs you can see here it's working over there because it just got the web hook - obviously spawn that workflow so it spawns the workflow job you see here go see ICT workflow and of course the first thing it's going to do is do an SCM update and and provision the infrastructure so it's going to it's going to update the code because again that ansible code could have changed we need that for the provisioning process so that happens dynamically then it's going to go on to provision fedora in this case a VM which is running in my cloud which is running on open stack but this could be AWS or Azure or GCP or something locally you can see here basically it just launched this this this instance here called go builder even gave it a name and so now we have that VM and now it's going to inventory it and you know because it needs to detect obviously IP addresses things like that so we can actually you know go to it and now we're gonna execute the playbook from the developers which is I think the interesting one here it's going to actually wait for the system to come up and and and then go in and start and start executing the the CI workflow essentially so you can see it made a connection now the first thing it's doing is installing golang that takes a little while so to install so while we're doing that why don't we go back to our our hello world application you can see now we have an additional branch so what I can do in this branch is I can basically do a pull request against this to create the pull request this doesn't push code it just creates a request and now you can see here that this is yellow and it's continuous integration go hello world pending ansible tower so I mean if I click here it'll actually bring me to ansible tower and you can see it's pending so we've Tower has automatically updated that to do that in this case what you're seeing here also is I have another CI CD workflow for something else I'm doing so that's kicking off as well but this is basically the one we're interested in and it's gonna go off now and and and wait until it hears back on what happened with with those tests so let's go back to to to the workflow it's still installing golang that's fine while we're waiting we can actually look at the web hooks I showed you that before so when we send the request I think it's kind of interesting git actually sends a payload and how we're able to know like what branch were using is because this all this information gets sent to tower and so basically the the branch here is important also the ID we need this otherwise we can't update the status of the pull request as well as you know who's the committer and that kind of thing it's very important so now we go through back to our back to our go build you can see it basically finished installed golang it created a source directory downloaded dependencies installed them and then it went to build the application and it failed undefined broken right because we put that thing in there so basically that failed and so now to go back here we can go back to we can go back to our our pull request here and we can see here in the pull request that it failed basically all checks have failed right so what we want to do is we want to go back and fix that so what we can do is now as a developer bring up my ID again I'm just going to change this there so it's not so it's fixed now so I fixed this issue I can go back here - s and we can see we changed something so I'm going to commit it now fix code and we can go get push origin patch - one and off its gonna go and this is gonna then execute our CI CD process again now the nice thing here is um also you know we never got to clean up so our instance actually still is still there I mean you could have cleaned it up if we wanted to but in this case we're not we're leaving it we're leaving it there because the idea is probably the developer is going to you know want to fix their code and change things so until that workflow completes but again you could also make that behave differently if you wanted to so now I'm going to go into tower here and we can see basically here it kicked off already the jobs so it's already doing kicking off the the workflow here and it's just started the build again so we can go look at that again it's it's going to wait or connectivity there's a timeout on that so it takes a little bit for the instance to come up and then this time it should go once it connects a lot faster because it's already installed basically you know the system's already there so it already went through these steps of course when we you know when we build software components you know there's a lot of artifacts left over and can take really long to build stuff like builds can take hours so this is actually really cool because the stuffs already there we basically with ansible just left off where we did before and we left off we left off at at the build what you can see here successfully now it completed then we actually start the web service and we actually ping the web service actually we do a request against it to test an acceptance test and then we kill the web service so you can actually see here in in here whoops that one this one the test the web service you can see basically I did a post against status and it returns hello world and that's what basically I'm looking for so that's how I did my acceptance test and then of course if we go back to jobs we'll see here that it removed the instance right so once it's successfully ran it removed the instance now if I go back to my infrastructure platform which I need to login to again that that VM in OpenStack should no longer be there so again it's gone so everything cleaned up and now as a last step if I go back to github I can actually see here now in my request that all the checks have passed right so I can actually merge this so now I'm that of course to a code review potentially before I merge it but now I'm the lady in our diagram that's coming in and I can basically say confirm merge and off I go done and of course now what's going to happen in this case since I just merged a master it's going to take off this pipeline again because now that we move the code master there may be other components and master that need to be tested or what-have-you and I'm not going to wait for all this to finish but you can see basically those those pipelines go get started again there so basically that should give you an idea of how this works hopefully it was interesting I thank you for your time and attention and if you're interested further feel free to reach out to me thank you very much
Info
Channel: Keith Tenzer
Views: 30,724
Rating: undefined out of 5
Keywords: CI/CD, Ansible Tower, Github, Simple, Powerful, Automation, Go, NOJenkins
Id: lyk-CRVXs8I
Channel Id: undefined
Length: 13min 35sec (815 seconds)
Published: Fri Jun 21 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.