Problem scenario
You run an ansible-playbook command, but you get "ERROR! the field hosts is required but was not set". What should you do?
Solution
Find the hyphens beneath the top "- name" stanza. Eliminate them. For example, if your playbook looks like this:
- name: Foobar
hosts: localhost
- vars:
goodone: "blahblah"
-tasks:
…
Make it look like this:
- name: Foobar
hosts: localhost
vars:
goodone: "blahblah"
tasks:
…
Now re-run it. (The root cause of this problem in all likelihood is syntax.)