Raise error in case of empty hosts list in playbook (#56354)

Fixes cases of playbook contaiing:
- hosts:
  -
ERROR! Unexpected Exception, this is probably a bug: sequence item 0: expected string, NoneType found
pull/56731/head
Marcin 6 years ago committed by Brian Coca
parent e13566140a
commit afc678e2c7

@ -103,6 +103,8 @@ class Play(Base, Taggable, CollectionSearch):
@staticmethod
def load(data, variable_manager=None, loader=None, vars=None):
if ('name' not in data or data['name'] is None) and 'hosts' in data:
if data['hosts'] is None or all(host is None for host in data['hosts']):
raise AnsibleParserError("Hosts list cannot be empty - please check your playbook")
if isinstance(data['hosts'], list):
data['name'] = ','.join(data['hosts'])
else:

Loading…
Cancel
Save