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:
parent
e13566140a
commit
afc678e2c7
1 changed files with 2 additions and 0 deletions
|
@ -103,6 +103,8 @@ class Play(Base, Taggable, CollectionSearch):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def load(data, variable_manager=None, loader=None, vars=None):
|
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 ('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):
|
if isinstance(data['hosts'], list):
|
||||||
data['name'] = ','.join(data['hosts'])
|
data['name'] = ','.join(data['hosts'])
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in a new issue