Introduction to Ansible Transcripts
Chapter: Running Playbooks
Lecture: YAML in the Playbook File

Login or purchase this course to watch this video and the rest of the course contents.
0:00 Now that we're ready to write our Playbook switch over into your development environment. I'll be writing this code on Ubuntu 18.04.
0:07 If you're working on a Mac you should be able to follow along with the same commands. And again, unfortunately on Windows, Ansible is not set up
0:13 to run on Windows as a command machine. You can control Windows machines from Ansible but executing Ansible Playbooks
0:19 really doesn't work even for basic purposes on Windows. First thing we're going to want to do is create a directory for our first Playbook.
0:26 Switch into that directory and, of course, it'll be empty. We need to write a first YAML file. Throughout these videos, I'm going to be using Vim
0:35 but if you're more comfortable in Sublime Text or another editor, feel free to use that instead. Start out with a little note
0:40 and you can put whatever comments to yourself that'll help you remember what this file is for. It just is, these are high-level instructions
0:45 that tell Ansible which tasks to apply to which hosts. Now we're going to write some YAML. This YAML instructs Ansible to take every host
1:03 in the inventory file that we'll write. We're going to use the root user which, typically, we would not do when we configure a server.
1:10 We'll learn how to lock down a server later. But, for simplicity's sake we're going to use the root user on the server that we provision.
1:16 We're only going to have a single role and that will be common. So what we've said here in this Playbook with high-level instructions, take every host
1:23 we're only going to have a single host on that hose, use the root user and apply the common role to all those hosts.
1:28 Here's how we know which host to apply it to. Create a host file. In the host file, specify the role named common.
1:38 Now we need to say which server we're going to apply this to. And we need the IP address, but we don't have a server yet.
1:44 So let's go to DigitalOcean and provision a server and then we'll know what to put in here.


Talk Python's Mastodon Michael Kennedy's Mastodon