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
This commit is contained in:
Marcin 2019-05-21 17:11:16 +02:00 committed by Brian Coca
parent e13566140a
commit afc678e2c7

View file

@ -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: