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
0:02 got comfortable with inventory files
0:04 roles, templates, and tasks within those roles.
0:07 Now we're going to enhance our Playbook by setting variables
0:09 that can be reused and greatly increase
0:11 the maintainability of the Playbooks that we write.
0:13 Reading environment variables particularly
0:15 for sensitive information that we don't want to keep stored
0:18 in files or that may vary from one server to another
0:21 and therefore we don't have the ability
0:22 to hard code in a variables file.
0:24 Let's take a look at using templates
0:26 as a different type of input data than variables
0:28 but incredibly useful in their own way.
0:29 And of course our variables often store
0:31 very sensitive information that we would want to encrypt
0:34 so that we can add it to source control
0:36 but not want to expose it to anyone as plain text.
0:38 As we left our last Playbook
0:40 when ended the previous chapter
0:41 our first Playbook had an inventory file
0:43 a top-level YAML file, a single role named common
0:46 with two tasks files main.yml and new_user.yml
0:49 We're first going to improve our Playbook
0:51 by adding variables under the group_vars directory
0:54 and we'll see how we can add variables to the all file
0:57 or the files that would be specific only to a single role.
1:00 We'll then take a look at how we can use templates
1:02 to configure services such as the Nginx web server
1:05 and we'll combine the two using variables
1:07 and templates as a very flexible way
1:09 to handle configuration management.
1:10 For example, let's say we have a variable named fqdn
1:13 which stands for fully qualified domain name.
1:15 That could be stored in the group_vars/all file
1:18 and then we would have a template file
1:19 for the Nginx configuration, and we could use
1:22 that variable fqdn within the template file.
1:24 We'd keep separation between the variables stored
1:27 in a separate set of files in the variables directory
1:30 and our templates which can be unique to our roles.
1:33 Let's see how this works in practice.