summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbhijit Menon-Sen <ams@2ndQuadrant.com>2016-07-01 06:23:57 +0530
committerJames Cammarata <jimi@sngx.net>2016-09-23 10:39:06 -0500
commitcc71765d9eea0f3da08e6bc9d69b7ee488e0e1e2 (patch)
tree55a4bb2fafd688fd7d16e8b1eae204242092c8d9
parentb5b8a756fcc3b99d9e05c110ed145aa916c9c43f (diff)
downloadansible-cc71765d9eea0f3da08e6bc9d69b7ee488e0e1e2.tar.gz
Use loop_control.loop_var directly
6eefc11c converted task.loop_control into an object, but while the other callers were updated to use .loop_var instead of .get('loop_var'), this site was overlooked. This can be reproduced by including with loop_control a file that does set_fact; a simple regression test along these lines is included. (cherry picked from commit 950cc26aab01e20a8b942958d640dca38788b3e9)
-rw-r--r--lib/ansible/executor/process/result.py2
-rw-r--r--test/integration/test_includes.yml2
-rw-r--r--test/integration/test_includes3.yml7
-rw-r--r--test/integration/test_includes4.yml2
4 files changed, 12 insertions, 1 deletions
diff --git a/lib/ansible/executor/process/result.py b/lib/ansible/executor/process/result.py
index 1e53d9191b..cdd32de498 100644
--- a/lib/ansible/executor/process/result.py
+++ b/lib/ansible/executor/process/result.py
@@ -173,7 +173,7 @@ class ResultProcess(multiprocessing.Process):
# if this task is registering facts, do that now
loop_var = 'item'
if result._task.loop_control:
- loop_var = result._task.loop_control.get('loop_var') or 'item'
+ loop_var = result._task.loop_control.loop_var or 'item'
item = result_item.get(loop_var, None)
if result._task.action == 'include_vars':
for (key, value) in iteritems(result_item['ansible_facts']):
diff --git a/test/integration/test_includes.yml b/test/integration/test_includes.yml
index 5c191b427c..d7303880f1 100644
--- a/test/integration/test_includes.yml
+++ b/test/integration/test_includes.yml
@@ -1 +1,3 @@
- include: test_includes2.yml parameter1=asdf parameter2=jkl
+
+- include: test_includes3.yml
diff --git a/test/integration/test_includes3.yml b/test/integration/test_includes3.yml
new file mode 100644
index 0000000000..012ee20568
--- /dev/null
+++ b/test/integration/test_includes3.yml
@@ -0,0 +1,7 @@
+---
+- hosts: localhost
+ tasks:
+ - include: test_includes4.yml
+ with_items: ["a"]
+ loop_control:
+ loop_var: r
diff --git a/test/integration/test_includes4.yml b/test/integration/test_includes4.yml
new file mode 100644
index 0000000000..bee906bdfb
--- /dev/null
+++ b/test/integration/test_includes4.yml
@@ -0,0 +1,2 @@
+- set_fact:
+ p: 1