1

I have a simple playbook and I want to enter the host interactively. My code looks like:

- hosts: "{{my_hosts}}"

vars_prompt:
- name: "my_hosts" 
  prompt: "Enter the hosts" 
  private: no

This code works fine in 2.3 and 2.4, but in 2.5 I get the message below. I haven't seen anything in the release notes that would explain why it stopped working. Anyone knows why?

Thanks,

a

ERROR! The field 'hosts' has an invalid value, which includes an undefined variable. The error was: 'scraper_hosts' is undefined

The error appears to have been in 'my-playbook.yml': line 8, column 3, but may be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:


- hosts: "{{my_hosts}}"
^ 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 }}

Should be written as:

with_items:
  - "{{ foo }}"
Alain
  • 532
  • 6
  • 15

1 Answers1

1

Looks like its not intended behavior, please check reported issue at github.

Fix is on its way according to this linked pull request.

ilias-sp
  • 6,135
  • 4
  • 28
  • 41
  • 1
    Thanks. I need to start looking at those bug trackers. Maybe I should go past the first page next time I search on google. – Alain May 11 '18 at 13:38
  • Well, i had a similar experience with you a few weeks ago, and was advised to open an issue at github, thats how/why i got familiar with the process. [my issue if interested, it was fixed in 2.5.2 by the way](https://stackoverflow.com/questions/49983209/ansible-cannot-append-into-a-list-in-a-with-items-loop). Cheers. – ilias-sp May 11 '18 at 13:47