Introduction to Ansible Transcripts
Chapter: Deployments
Lecture: Learning Ansible Modules by Deploying
Login or
purchase this course
to watch this video and the rest of the course contents.
0:00
In this chapter we're going to take all the knowledge that we've learned throughout the course
0:04
and we're going to put it together into a complete playbook that will deploy an application. We are going to use a Python web application
0:10
as our example. But if you have limited knowledge of how to build and operation Python applications that should not matter to you learning how to use
0:17
more features of Ansible. Our example application is a simple prototype Git Commit History Dashboard built with Python in Flask.
0:25
There isn't much to this application. It's a work-in-progress. It's exactly the type of early application
0:30
that we'd want to be able to deploy to a server so that we could show it off to somebody and get feedback on it. Here's what it looks like.
0:36
To access the application source code it's all open source under the MIT license github.com/fullstackPython/flaskgitdashboard.
0:48
Here's how our deployment is going to be structured. Some of this is already in place so while there are a lot of pieces here
0:53
in this chapter we're really just going to be adding the new components, beyond what we had in our playbook from the previous chapter.
0:59
As with most applications, you're going to have a bunch of users, which is what it's in the top left corner of this diagram.
1:05
They may be accessing your application from phones, tablets, web browsers on their laptops and desktop computers
1:11
and you're going to have your development environment as well where you are building the application.
1:14
So what we need are a way to get the source code on to our remote servers and we need a way for users to be able
1:20
to access the application via the internet. Here are the components that we have in place so far and what we're going to set up throughout the chapter.
1:26
The first step is going to be getting a URL. We're going to be use ansibledeploymentexample.com.
1:31
We use the domain name system to have that URL correspond to an IP address, which is our web server which we already have set up.
1:38
That web server, which is running Nginx while like any good web server should be running HTTP secure, HTTPS.
1:44
We'll grab a free certificate from Let's Encrypt and we're going to automate this whole process so that whatever applications you decide to deploy
1:50
in the future, you can customize your playbook run it again, and every single step is automated.
1:55
No manual configuration that you're going to have to do. Once we have our HTTPS certificate we have to get our source code onto the server.
2:02
Now that source code is stored on GitHub which we us our local development environment to create the code, write the code, then push up GitHub.
2:08
Then from our web server, we're going to obtain that source code from GitHub. Once we got the source code
2:12
we can handle the Python specific configuration that's necessary, along with any static assets
2:17
that we have that we need to serve through our web server. Our application will also have application dependencies
2:22
which we're going to need to grab from PyPI which is the Python package index which allows us to retrieve code library dependencies
2:29
such as our web framework Flask. When our application is up and running we'll then connect to the database and we already have our database running
2:36
from the previous chapter but we need to do some custom configuration to make sure we can connect to it properly and interact with it.
2:41
So that's how our deployment is going to go throughout this chapter and we're going to learn a bunch more Ansible modules.
2:45
Hopefully regardless of whether you're working with Python web applications or another programming language and your just happen to be using Ansible
2:53
as your configuration tool all of this knowledge will be helpful to you. And with some tweaking should be able to deploy Javascript, Ruby, Java
3:00
and other applications. To grab all the code from this chapter including the finished Ansible playbook take a look at bit.ly/intro-ansible/ch7.
3:08
Let's dig in.