Defining & Using vars in a Play
Declare values and reference them.
Why Variables Exist
Hardcoding values like a port or package name everywhere makes change painful. A variable names a value once so you can reuse it. 🌟
The vars Section
Inside a play you add a vars key holding a mapping of names to values. Everything under it becomes available to that play's tasks.
- hosts: web
vars:
http_port: 80
app_name: shop
tasks: []All lessons in this course
- Defining & Using vars in a Play
- The {{ }} Substitution Syntax
- Extra Vars on the Command Line
- Where Variables Come From & Precedence