include_vars
Collection: builtin
Full Name: parallax.builtin.include_vars
Aliases: ansible.builtin.include_vars, include_vars
Synopsis
Load variables from a file or directory into the play
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
| file | string | The file name from which variables should be loaded | ||
| dir | string | The directory name from which the variables should be loaded | ||
| name | string | The name of a variable into which assign the included vars | ||
| depth | int | 0 | When using dir, this module will, by default, recursively go through each sub directory and load up the variables | |
| files_matching | string | Limit the files that are loaded within any directory to this regular expression | ||
| ignore_files | list | List of file names to ignore | ||
| extensions | list | [json yaml yml] | List of file extensions to read when using dir | |
| ignore_unknown_extensions | bool | false | Ignore files with extensions that are not in the extensions list | |
| free_form | string | This module allows you to specify the ‘file’ option directly as a path |
Example
- name: Load the environment's variables
include_vars:
file: "vars/{{ deploy_env }}.yml"
- name: Load every YAML file in a directory
include_vars:
dir: vars/common
extensions:
- yml
- yaml