Skip to content

Instantly share code, notes, and snippets.

@juliedavila
Created June 29, 2015 18:36
Show Gist options
  • Save juliedavila/0c687a3d1b5f9c5e432c to your computer and use it in GitHub Desktop.
Save juliedavila/0c687a3d1b5f9c5e432c to your computer and use it in GitHub Desktop.
Variable leakage example
---
- hosts: all
gather_facts: no
connection: local
vars:
varname: "from_vars"
rolevar: "from_vars"
pre_tasks:
## This prints out the value defined in the 'rrr' role vars/main.yml, not the value from vars above which is what should happen
- debug: msg="In main rolevar {{rolevar}}"
roles:
- { role: rrr, varname: "from_params" }
tasks:
## This evaluates to "from_params" from the role call
- debug: msg="In main {{varname}}"
## This evaluates to a value only defined in rrr/defaults/main.yml; this should error.
- debug: msg="In main default var {{default_role_var}}"
- include: foo.yml
vars:
varname: from_params_to_include
## After ANY include, this then evaluates to "from_vars" (this is the expected behavior but should have happened in line 19 too)
- debug: msg="In main {{varname}}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment