Propagating variables within a playbook

20 views
Skip to first unread message

Dejay Clayton

unread,
Mar 23, 2016, 3:12:16 PM3/23/16
to Ansible Project
I've discovered behavior that seems to indicate that Ansible's handling of variables and facts is even more brittle than I had originally guessed.  I hope that's not the case; I hope I'm just being dense.

Could someone verify whether the following behavior is intended?  If so, I'll just go back to using Bash scripts.

$ ansible-playbook -i=localhost, play1.yml
ERROR! 'test_fact' is undefined

$ cat play1.yml

# play1.yml
---
- hosts: localhost
  tasks:
    - set_fact: test_fact='hello'

- include: "{{ test_fact }}"

$ ansible-playbook -i=localhost, play2.yml
ERROR! 'test_fact' is undefined

$ cat play2.yml

# play2.yml
---
- hosts: localhost
  vars:
    test_fact: 'hello'

- include: "{{ test_fact }}"
Reply all
Reply to author
Forward
0 new messages