I have upgraded to Ansible 2.5 right now and facing an issue with variable hosts such as:
---
- hosts: "{{ dbhosts }}"
gather_facts: false
vars_prompt:
- name: dbhosts
prompt: "Which hosts would you like to run?"
private: no
default: all
tasks:
- debug:
var: hostvars
`
ERROR! The field ‘hosts’ has an invalid value, which includes an undefined variable. The error was: ‘dbhosts’ is undefined The error appears to have been in ‘/ansible/playbooks/tester.yaml’: line 3, column 3, but may be elsewhere in the file depending on the exact syntax problem. The offending line appears to be: — - hosts: “{{ dbhosts }}” ^ here We could be wrong, but this one looks like it might be an issue with missing quotes. Always quote template expression brackets when they start a value. For instance: with_items: - {{ foo }}
`
The same playbook was running fine with Ansible 2.4.
Is there any specific change that I should follow in Ansible 2.5?
The fix is also linked in the bug report at: https://github.com/ansible/ansible/pull/38000. I pulled the fixed file and my install of 2.5.0 is now working as expected in terms of vars_prompt.