diff options
author | Brian Coca <bcoca@users.noreply.github.com> | 2019-04-29 17:59:10 -0400 |
---|---|---|
committer | Toshio Kuratomi <a.badger@gmail.com> | 2019-04-29 19:03:58 -0500 |
commit | 57935b76d750a87616cec0dbeabf194bbd8b7e15 (patch) | |
tree | 08570d36ad67dfc402bd139f6d645894636dca1c | |
parent | 630e8cb8e2b39d13122b22f164da77964f9e6366 (diff) | |
download | ansible-57935b76d750a87616cec0dbeabf194bbd8b7e15.tar.gz |
allow empty plays again, for now (#55878)
(cherry picked from commit 815a375177345fa88fcc995f144cad39b9988591)
-rw-r--r-- | changelogs/fragments/bad_empty_play.yml | 2 | ||||
-rw-r--r-- | lib/ansible/playbook/__init__.py | 4 |
2 files changed, 5 insertions, 1 deletions
diff --git a/changelogs/fragments/bad_empty_play.yml b/changelogs/fragments/bad_empty_play.yml new file mode 100644 index 0000000000..a0a4b4893f --- /dev/null +++ b/changelogs/fragments/bad_empty_play.yml @@ -0,0 +1,2 @@ +bugfixes: + - re allow empty plays for now, but add deprecation msg. diff --git a/lib/ansible/playbook/__init__.py b/lib/ansible/playbook/__init__.py index 0321615505..74257c061b 100644 --- a/lib/ansible/playbook/__init__.py +++ b/lib/ansible/playbook/__init__.py @@ -69,12 +69,14 @@ class Playbook: 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 - if not ds: + if ds is None: self._loader.set_basedir(cur_basedir) raise AnsibleParserError("Empty playbook, nothing to do", obj=ds) elif not isinstance(ds, list): self._loader.set_basedir(cur_basedir) 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 # using the Play() object, and includes are parsed using the |