Hi,
If I call ansible-playbook using: -e “foo=bar”, I know I can use {{ foo }} in the vars_files of a playbook, but can the variable foo be used in tasks?
I just tried to run:
… in the playbook tasks and it came up blank!?
Thanks
GS
Here’s another example that doesn’t work:
- hosts: “{{ target }}”
vars_files:
- vars/{{ environment }}.yaml
tasks:
- debug: msg=“{{ environment }}”
when: environment == ‘test’
If I run this playbook with -e “environment=test”, Ansible says “skipping” for the debug task. Any ideas?
GS
I think using the variable “environment” was a bad move as Ansible uses that for setting environment variables. I changed that to ‘env’ and it worked a lot better.
GS