Running Ansible 2.1.1
I want to dynamically build the variable name for a file I wish to load using “include_vars.” it doesn’t work using the lookup plugin but the lookup plugin itself does work when I use the “debug” method.
- name: load var file
include_vars: “{{ lookup(‘ini’,‘environment section=environment_info file=/etc/abc123.conf’) }}.yml”
Error:
`
TASK [sam : load var file] *****************************************************
task path: /home/ssen/ansible_ops/roles/sam/tasks/main.yml:5
An exception occurred during task execution. The full traceback is:
Traceback (most recent call last):
File “/usr/lib/python2.7/site-packages/ansible/executor/task_executor.py”, line 124, in run
res = self._execute()
File “/usr/lib/python2.7/site-packages/ansible/executor/task_executor.py”, line 448, in _execute
result = self._handler.run(task_vars=variables)
File “/usr/lib/python2.7/site-packages/ansible/plugins/action/include_vars.py”, line 39, in run
source = self._loader.path_dwim_relative(self._task._role._role_path, ‘vars’, source)
File “/usr/lib/python2.7/site-packages/ansible/parsing/dataloader.py”, line 236, in path_dwim_relative
if source.startswith(‘~’) or source.startswith(‘/’):
AttributeError: ‘NoneType’ object has no attribute ‘startswith’
fatal: [localhost]: FAILED! => {“failed”: true, “msg”: “Unexpected failure during module execution.”, “stdout”: “”}
`