Skip to content

Instantly share code, notes, and snippets.

@kustodian
Created April 21, 2017 14:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kustodian/5bfd237fe134037eb6d522ea649216e9 to your computer and use it in GitHub Desktop.
Save kustodian/5bfd237fe134037eb6d522ea649216e9 to your computer and use it in GitHub Desktop.
Ansible include_vars sets host facts (host vars)
# host_vars/localhost.yml
---
var1: inventory
---
- hosts: localhost
gather_facts: no
vars:
var1: play
tasks:
- debug:
var: var1
- debug:
var: hostvars[inventory_hostname].var1
- include_vars: vars.yml
- debug:
var: var1
- debug:
var: hostvars[inventory_hostname].var1
- hosts: localhost
gather_facts: no
tasks:
- debug:
var: var1
- debug:
var: hostvars[inventory_hostname].var1
---
var1: include_vars
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment