Introduction to Ansible Transcripts
Chapter: Data
Lecture: Working with Data

Login or purchase this course to watch this video and the rest of the course contents.
0:00 In the previous chapter, we started our first Playbook got comfortable with inventory files roles, templates, and tasks within those roles.
0:08 Now we're going to enhance our Playbook by setting variables that can be reused and greatly increase
0:12 the maintainability of the Playbooks that we write. Reading environment variables particularly
0:16 for sensitive information that we don't want to keep stored in files or that may vary from one server to another
0:22 and therefore we don't have the ability to hard code in a variables file. Let's take a look at using templates
0:27 as a different type of input data than variables but incredibly useful in their own way. And of course our variables often store
0:32 very sensitive information that we would want to encrypt so that we can add it to source control but not want to expose it to anyone as plain text.
0:39 As we left our last Playbook when ended the previous chapter our first Playbook had an inventory file a top-level YAML file, a single role named common
0:47 with two tasks files main.yml and new_user.yml We're first going to improve our Playbook by adding variables under the group_vars directory
0:55 and we'll see how we can add variables to the all file or the files that would be specific only to a single role.
1:01 We'll then take a look at how we can use templates to configure services such as the Nginx web server and we'll combine the two using variables
1:08 and templates as a very flexible way to handle configuration management. For example, let's say we have a variable named fqdn
1:14 which stands for fully qualified domain name. That could be stored in the group_vars/all file and then we would have a template file
1:20 for the Nginx configuration, and we could use that variable fqdn within the template file. We'd keep separation between the variables stored
1:28 in a separate set of files in the variables directory and our templates which can be unique to our roles. Let's see how this works in practice.

Talk Python's Mastodon Michael Kennedy's Mastodon