allow empty plays again, for now (#55878)
This commit is contained in:
parent
cb0ca89994
commit
815a375177
2 changed files with 5 additions and 1 deletions
2
changelogs/fragments/bad_empty_play.yml
Normal file
2
changelogs/fragments/bad_empty_play.yml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
bugfixes:
|
||||||
|
- re allow empty plays for now, but add deprecation msg.
|
|
@ -69,12 +69,14 @@ class Playbook:
|
||||||
raise AnsibleParserError("Could not read playbook (%s) due to encoding issues: %s" % (file_name, to_native(e)))
|
raise AnsibleParserError("Could not read playbook (%s) due to encoding issues: %s" % (file_name, to_native(e)))
|
||||||
|
|
||||||
# check for errors and restore the basedir in case this error is caught and handled
|
# check for errors and restore the basedir in case this error is caught and handled
|
||||||
if not ds:
|
if ds is None:
|
||||||
self._loader.set_basedir(cur_basedir)
|
self._loader.set_basedir(cur_basedir)
|
||||||
raise AnsibleParserError("Empty playbook, nothing to do", obj=ds)
|
raise AnsibleParserError("Empty playbook, nothing to do", obj=ds)
|
||||||
elif not isinstance(ds, list):
|
elif not isinstance(ds, list):
|
||||||
self._loader.set_basedir(cur_basedir)
|
self._loader.set_basedir(cur_basedir)
|
||||||
raise AnsibleParserError("A playbook must be a list of plays, got a %s instead" % type(ds), obj=ds)
|
raise AnsibleParserError("A playbook must be a list of plays, got a %s instead" % type(ds), obj=ds)
|
||||||
|
elif not ds:
|
||||||
|
display.deprecated("Empty plays will currently be skipped, in the future they will cause a syntax error", version='2.12')
|
||||||
|
|
||||||
# Parse the playbook entries. For plays, we simply parse them
|
# Parse the playbook entries. For plays, we simply parse them
|
||||||
# using the Play() object, and includes are parsed using the
|
# using the Play() object, and includes are parsed using the
|
||||||
|
|
Loading…
Reference in a new issue