Introduction to Ansible Transcripts
Chapter: Deployments
Lecture: Installing App Dependencies with venv and pip3

Login or purchase this course to watch this video and the rest of the course contents.
0:00 We now have our source code on our web server
0:02 but nothing is running.
0:03 So, what we want to do in the next step
0:06 is install our application dependencies with pip
0:08 into a virtual environment, which provides
0:11 dependency isolation for Python applications, and then
0:14 stand up our WSGI web server gateway interface server.
0:17 Once that's done, we can also test out
0:19 our NGINX configuration.
0:21 Make sure we didn't make any other mistakes there.
0:22 We should be able to serve up static assets
0:24 like JavaScript, CSS, images, those sorts of things.
0:28 Let's take the next step to create our virtual environment
0:30 install our dependencies with pip
0:32 and then we'll be ready to set up our WSGI server.
0:37 Head back up into roles/webserver/tasks.
0:41 Modify main.yml.
0:46 We're ready to create a new file dependencies.yml.
1:00 Now, we want to make sure we've got a couple
1:01 of packages installed.
1:03 One of them Python pip should already be installed
1:05 but we'll add it to our list here, just in case.
1:07 So, there's no harm in adding a package name
1:10 as a check to see if it should be installed
1:12 and if it already is installed, it'll just be skipped over.
1:15 So, we're going to go back and use the ebt module.
1:28 We need superuser privileges.
1:37 All right, now we want to create a virtual environment.
1:45 We're going to check to see if it's already created.
1:47 If it is, we'll avoid this step.
1:56 Now, if it's not created
1:57 we will create a directory for it.
1:59 We'll run the command to create a virtual environment.
2:12 And we'll create a new variable for VM directory.
2:22 Then finally, with our virtual env in place
2:24 we can use the pip3 command to install the dependencies
2:27 that our application lists into our virtual environment.
2:50 Okay, let's add a venv_dir to our variables.
3:03 And this will be outside of our git repository directory.
3:08 Okay.
3:10 Those should be the new tasks that we need our web server
3:13 to install the application dependencies for our application.