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

NameTypeRequiredDefaultDescription
filestringThe file name from which variables should be loaded
dirstringThe directory name from which the variables should be loaded
namestringThe name of a variable into which assign the included vars
depthint0When using dir, this module will, by default, recursively go through each sub directory and load up the variables
files_matchingstringLimit the files that are loaded within any directory to this regular expression
ignore_fileslistList of file names to ignore
extensionslist[json yaml yml]List of file extensions to read when using dir
ignore_unknown_extensionsboolfalseIgnore files with extensions that are not in the extensions list
free_formstringThis 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