Ansible Module include vars: Difference between revisions
Jump to navigation
Jump to search
Line 5: | Line 5: | ||
=Overview= | =Overview= | ||
The module Loads YAML/JSON variables dynamically from a file or directory, recursively, during task runtime. If loading a directory, the files are sorted alphabetically before being loaded. | The module Loads YAML/JSON variables dynamically from a file or directory, recursively, during task runtime. If loading a directory, the files are sorted alphabetically before being loaded. | ||
=Use Cases= | |||
====Load Variables in a Playbook before Roles and Task Execution==== | |||
<syntaxhighlight lang='yaml'> | |||
- name: some play | |||
hosts: localhost | |||
pre_tasks: | |||
- include_vars: | |||
file: '<filename-relative-to-playbook-dir>.yaml' | |||
roles: | |||
- ... | |||
tasks: | |||
- ... | |||
</syntaxhighlight> |
Revision as of 17:07, 5 July 2021
External
Internal
Overview
The module Loads YAML/JSON variables dynamically from a file or directory, recursively, during task runtime. If loading a directory, the files are sorted alphabetically before being loaded.
Use Cases
Load Variables in a Playbook before Roles and Task Execution
- name: some play
hosts: localhost
pre_tasks:
- include_vars:
file: '<filename-relative-to-playbook-dir>.yaml'
roles:
- ...
tasks:
- ...