summaryrefslogtreecommitdiff
path: root/lib/ansible/playbook
diff options
context:
space:
mode:
authorRick Elrod <rick@elrod.me>2021-04-09 09:28:24 -0500
committerGitHub <noreply@github.com>2021-04-09 10:28:24 -0400
commitef554d03785dff43a03a1121e921eb55ff5c0bb4 (patch)
treec164d7728efa671af2ea24f21e6977f768f535f6 /lib/ansible/playbook
parentbecf9416736dc911d3411b92f09512b4dae2955c (diff)
downloadansible-ef554d03785dff43a03a1121e921eb55ff5c0bb4.tar.gz
[playbook] error on empty, error on 'include' (remove two deprecations) (#74172)
Change: - Remove two deprecated features - We now error if a playbook is an empty list instead of just skipping - We now error if using 'include' instead of 'import_playbook' Test Plan: - Added new tests for new errors Tickets: - Fixes #74133 Signed-off-by: Rick Elrod <rick@elrod.me> * sanity & changelog Signed-off-by: Rick Elrod <rick@elrod.me>
Diffstat (limited to 'lib/ansible/playbook')
-rw-r--r--lib/ansible/playbook/__init__.py13
-rw-r--r--lib/ansible/playbook/playbook_include.py2
2 files changed, 6 insertions, 9 deletions
diff --git a/lib/ansible/playbook/__init__.py b/lib/ansible/playbook/__init__.py
index 8c4ed65f0b..0dbb38e43b 100644
--- a/lib/ansible/playbook/__init__.py
+++ b/lib/ansible/playbook/__init__.py
@@ -79,8 +79,8 @@ class Playbook:
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', collection_name='ansible.builtin')
+ self._loader.set_basedir(cur_basedir)
+ raise AnsibleParserError("A playbook must contain at least one play")
# Parse the playbook entries. For plays, we simply parse them
# using the Play() object, and includes are parsed using the
@@ -89,18 +89,15 @@ class Playbook:
if not isinstance(entry, dict):
# restore the basedir in case this error is caught and handled
self._loader.set_basedir(cur_basedir)
- raise AnsibleParserError("playbook entries must be either a valid play or an include statement", obj=entry)
+ raise AnsibleParserError("playbook entries must be either valid plays or 'import_playbook' statements", obj=entry)
- if any(action in entry for action in C._ACTION_ALL_IMPORT_PLAYBOOKS):
- if any(action in entry for action in C._ACTION_INCLUDE):
- display.deprecated("'include' for playbook includes. You should use 'import_playbook' instead",
- version="2.12", collection_name='ansible.builtin')
+ if any(action in entry for action in C._ACTION_IMPORT_PLAYBOOK):
pb = PlaybookInclude.load(entry, basedir=self._basedir, variable_manager=variable_manager, loader=self._loader)
if pb is not None:
self._entries.extend(pb._entries)
else:
which = entry
- for k in C._ACTION_IMPORT_PLAYBOOK + C._ACTION_INCLUDE:
+ for k in C._ACTION_IMPORT_PLAYBOOK:
if k in entry:
which = entry[k]
break
diff --git a/lib/ansible/playbook/playbook_include.py b/lib/ansible/playbook/playbook_include.py
index 5b96690255..d65f7966f3 100644
--- a/lib/ansible/playbook/playbook_include.py
+++ b/lib/ansible/playbook/playbook_include.py
@@ -140,7 +140,7 @@ class PlaybookInclude(Base, Conditional, Taggable):
new_ds.ansible_pos = ds.ansible_pos
for (k, v) in iteritems(ds):
- if k in C._ACTION_ALL_IMPORT_PLAYBOOKS:
+ if k in C._ACTION_IMPORT_PLAYBOOK:
self._preprocess_import(ds, new_ds, k, v)
else:
# some basic error checking, to make sure vars are properly