Introduction to Ansible Transcripts
Chapter: Introduction
Lecture: Why Ansible?

Login or purchase this course to watch this video and the rest of the course contents.
0:00 You may have already set your heart on using Ansible, and so you don't really need reasons why. But I want to get you even more excited,
0:06 regardless of whether you've decided you're ready to use Ansible or you're evaluating alternative choices.
0:11 First off, after years of working in the DevOps space, I've found Ansible to be the easiest configuration management tool to use.
0:18 I had previously been working with Puppet and Chef, and just found that I couldn't keep up with what was going on with those tools.
0:24 There is a reason why Ansible exploded in popularity once it was released. But rather than me just tell you about how easy it is,
0:30 I want to show you a quick example. You can get a feel for what you're actually going to doing with Ansible.
0:35 I've switched over into my own development environment, and I have three windows here. The one at the top left has a single Ansible playbook file
0:43 with two tasks in it. The right-hand panel is where I've logged into a remote server that I've set up on DigitalOcean.
0:49 It's a blank server that has not yet been configured. And then on the bottom, we're going to run our Ansible playbook.
0:53 First, let's take a look at these two tasks on the top left corner. Both of these tasks use the same Ansible module. Don't worry if terminology like
1:01 playbooks, modules, tasks are unfamiliar. We're going to cover all those in depth in Chapter 3 after you get your own development environment set up.
1:08 For now, just bear with me as you take a look at what Ansible is able to do in just a few lines of the markup language, YAML, which Ansible uses
1:16 for its playbooks. The first task we have here uses the file module, and we specify a path. We want to create a directory named matt.
1:24 So we specify state of directory and the permissions we want for that directory as well. What will happen here is that if a directory does not exist,
1:31 home/Matt, it will create one. And if not, it'll just let that one be, or it'll change its permissions to match the permissions that we want
1:38 on our remote directory. The second task uses the same file module, but it creates a file named hello-ansible.md for markdown.
1:45 And the state, instead of saying we want a directory, we want to use a touch command to create an empty file,
1:49 and we give it some different permissions. So the gist here is, we want to create a directory, and we want to create a file within that directory.
1:54 If we look over here on the top right where I've logged into my remote server, we'll see that no files or directories exist under the home directory.
2:01 Let's run our Ansible playbook, and we'll see that that quickly changes. We're going to run the Ansible playbook command with a deploy.yml file.
2:09 We'll specify a private key that is located in my .ssh home directory. And we'll specify an inventory file which contains the
2:21 IP address for the remote server that we're working with. And the de facto standard is to call that inventory file hosts.
2:28 We'll kick off our playbook, and Ansible has reported back that it was able to execute three tasks.
2:33 First, gathering facts, so gathering all the configuration as it exists and then executing the two tasks
2:39 that we specified above in our Ansible playbook. Let's see what happened on our remote server. We've got our directory named matt now.
2:45 We can go into it, and we see we have a hello-ansible.md markdown file. So in just a few lines, we were able to modify
2:52 a remote server, and we could actually do that with more than a single server. We only changed one server here, but we could've run
2:58 the exact same file against thousands of servers. And we only used two tasks here. Tasks are the building blocks for entire playbooks
3:05 that allow us to set up servers in the exact configurations that we want, do our deployments, and handle thousands
3:10 of servers if we want using these maintainable playbooks. Throughout this course, you'll become completely comfortable
3:15 with this very simple playbook and building much more complicated playbooks for real-world scenarios.
3:20 I've used Ansible on applications ranging from side projects that I've built in my spare time to really large organizations, where dozens of developers
3:28 are working on the same deployments. Ansible's ease of use allows it to scale, both in team size
3:32 and in project size, and across many different projects. So what you're learning here, whether it's for a side project or for a large organization,
3:38 it'll be relevant in many scenarios. Ansible's approach to configuration management is to automate what was previously done by hand using Open SSH.
3:46 Other configuration management tools use an agent approach, which means that you have to have software running
3:50 on all of your remote machines, and that can create an additional attack factor that your information security department may say,
3:56 That's not going to happen. I gain peace of mind from knowing that Ansible is not creating a new paradigm.
4:00 It's taking decades of system administration experience and making that much easier, whether you are a sys admin or a developer who is trying to deploy
4:07 and configure servers. Finally, another huge thing for me is I've written playbooks, read them several years later,
4:12 and immediately understood what they were doing. I wasn't the biggest fan of YAML when I first saw it, but I quickly became comfortable with it.
4:18 And it has major advantages over other markup formats.


Talk Python's Mastodon Michael Kennedy's Mastodon