ansible/ansible — pull request #3791 by sergevanginderachter (2013-08-08 14:28:13+00:00)
Title: Check for ansible_facts in results for with_ tasks

that loop over a lookup plugin. Fixes #3704 and #3735

Given the playbook
``` yaml
- hosts: localhost
gather_facts: False
tasks:
- set_fact: specialvar={{item}}
with_items:
- a
- b
- c
- d
- debug: msg={{specialvar}}
```
gives:
``` yaml
TASK: [set_fact specialvar={{item}}] ******************************************
ok: [localhost] => (item=a)
ok: [localhost] => (item=b)
ok: [localhost] => (item=c)
ok: [localhost] => (item=d)

TASK: [debug msg={{specialvar}}] **********************************************
ok: [localhost] => {"msg": "{{specialvar}}"}
´´´
but with this patch this becomes:
``` yaml
TASK: [set_fact specialvar={{item}}] ******************************************
ok: [localhost] => (item=a)
ok: [localhost] => (item=b)
ok: [localhost] => (item=c)
ok: [localhost] => (item=d)

TASK: [debug msg={{specialvar}}] **********************************************
ok: [localhost] => {"msg": "d"}
```
Obviously there are more usefull examples (in my case using `with_random_choice`)