O'Reilly logo

Ansible Configuration Management - Second Edition by Daniel Hall

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Role defaults

The second feature included with Ansible 1.3 is variable default values. If you place a main.yml file in the defaults directory for the role, these variables will be read into the role; however, they can be overridden by variables in the vars/main.yml file, or the variables that are passed to the role when it is included. This allows you to make passing variables to the role optional. These files look exactly like other variable files. For example, if you used a variable named port in your role, and you want to default it to port 80, your defaults/main.yml file will look similar to the following code:

---
port: 80

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required