March 2019
Intermediate to advanced
412 pages
9h 49m
English
In certain scenarios, it may be desirable to parameterize the variable files to be loaded. It is possible to do this by using a variable as part of the filename; however, the variable must have a value defined at the time the playbook is parsed, just like when using variables in task names. Let's update our example play to load a variable file based on the data provided at execution time:
---
- name: vars
hosts: localhost
gather_facts: false
vars_files: - "{{ varfile }}" tasks: - name: a task debug: msg: "I am a {{ varname }}"
Now when we execute the playbook, we'll provide the value for varfile with the -e argument:
In addition to the variable value needing to be defined at execution time, the file to be loaded ...
Read now
Unlock full access