vars_files-When are the variables loaded?

78 views
Skip to first unread message

smal...@redhat.com

unread,
Dec 7, 2015, 4:24:28 PM12/7/15
to Ansible Project
In one my plays, a task executes a script that parses a file and exracts some credentials and saves them to a yaml file. If I try to access the variables in the file using vars_files it doesn't work as I guess ansible tries to figure out the values of the variables even before any of the tasks are executed. Since the tasks that sets up the yaml file isn't executed, ansible complains that the variable file isn't present. Even if try a task that writes the credentials to /etc/ansible/facts.d in json and try accessing them, ansible complains that the the ansible_local variable isn't present. Any workaround for this?

Brian Coca

unread,
Dec 7, 2015, 5:43:13 PM12/7/15
to Ansible Project
vars_files executes in the 'playbook compile phase' if you want to
dynamically load vars use include_vars module.

--
Brian Coca
Reply all
Reply to author
Forward
0 new messages