Vars defined in host file not getting the value when the value is supplied as extra vars during playbook run

8 views
Skip to first unread message

ishan jain

unread,
Aug 29, 2016, 6:44:05 AM8/29/16
to Ansible Project
My host file looks something like this:


[Group]

[Group:vars]
vars="{{src}}/varsFile.yaml


And in my playbook:

---
- hosts: "{{remote_hosts}}"
  vars_files:
     - "{{vars}}"
  gather_facts: yes
  tasks:
      ......


Now when i run this with the command:

ansible-playbook -i host playbook.yaml -e src=/opt/config

The playbook run fails as some variable (defined in varsFile.yaml) is not found.


But when i use the command:

ansible-playbook -i host playbook.yaml -e src=/opt/config -e vars=/opt/config/varsFile.yaml

Everything runs perfectly fine.

How can i make sure that when i provide this "src" as extra var, it can be used in multiple locations in my playbooks and host variables ?
Reply all
Reply to author
Forward
0 new messages