summaryrefslogtreecommitdiff
path: root/lib/ansible/playbook/helpers.py
diff options
context:
space:
mode:
authorJames Cammarata <jimi@sngx.net>2017-09-14 22:04:20 -0500
committerGitHub <noreply@github.com>2017-09-14 22:04:20 -0500
commitcd2774af7849be79f19b43628a3e3dde4bde00b4 (patch)
tree75cd8918040fc5efe3f14edf6139b26d2213af41 /lib/ansible/playbook/helpers.py
parentc027ad943e6c17387ab75e864170e3665a8e6635 (diff)
downloadansible-cd2774af7849be79f19b43628a3e3dde4bde00b4.tar.gz
Fixing two bugs with import_role (#30398)
1) import_role was never resulting in a static inclusion of the role tasks due to a logic error. 2) no error was raised when import_role tried to use a with loop, resulting in a strange error down the execution path.
Diffstat (limited to 'lib/ansible/playbook/helpers.py')
-rw-r--r--lib/ansible/playbook/helpers.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/ansible/playbook/helpers.py b/lib/ansible/playbook/helpers.py
index bb84d2cb77..78853437de 100644
--- a/lib/ansible/playbook/helpers.py
+++ b/lib/ansible/playbook/helpers.py
@@ -297,7 +297,7 @@ def load_list_of_tasks(ds, play, block=None, role=None, task_include=None, use_h
if 'import_role' in task_ds:
is_static = True
- if ir.static is not None:
+ elif ir.static is not None:
display.deprecated("The use of 'static' for 'include_role' has been deprecated. "
"Use 'import_role' for static inclusion, or 'include_role' for dynamic inclusion")
is_static = ir.static
@@ -320,6 +320,12 @@ def load_list_of_tasks(ds, play, block=None, role=None, task_include=None, use_h
display.debug('Determined that if include_role static is %s' % str(is_static))
if is_static:
+ if ir.loop is not None:
+ if 'import_tasks' in task_ds:
+ raise AnsibleParserError("You cannot use loops on 'import_role' statements. You should use 'include_role' instead.", obj=task_ds)
+ else:
+ raise AnsibleParserError("You cannot use 'static' on an include_role with a loop", obj=task_ds)
+
# we set a flag to indicate this include was static
ir.statically_loaded = True