Variables are used to store values that can be later used in your playbook. They can be set and overridden in multiple ways. Facts of machines can also be fetched as variables and used. Ansible allows you to set your variables in many different ways, that is, either by passing a variable file, declaring it in a playbook, passing it to the
ansible-playbook command using
-e / --extra-vars, or by declaring it in an inventory file (discussed later in this chapter).
Before we look at the preceding ways in a little more detail, let's look at some of the ways in which variables in Ansible can help you, as follows:
- set_fact package_name=httpd ...