Description
ISSUE TYPE
- Bug Report
COMPONENT NAME
with_items
ANSIBLE VERSION
2.5.1-1.el7ae
CONFIGURATION
OS / ENVIRONMENT
RHEL 7.4
SUMMARY
I have a very simple play to reproduce a much larger problem we are having. Given the playbook below, we get very different results between ansible versions 2.5.0 and 2.5.1.
Given a with_items loop that is appending values from one list to another list, the result with 2.5.0 is that the second list contains all of the entries from the first list, but with 2.5.1 the second list only contains the last entry from the first list. It looks like in 2.5.1 that the entire list is overwritten with each loop iteration instead of appending to the list. This happens with strings and well as lists.
STEPS TO REPRODUCE
This very simple reproducer playbook consistently reproduces the problem with 2.5.1. The problem does not exist when using the same playbook with 2.5.0.
- hosts: localhost
become: yes
gather_facts: no
vars:
foo:
- bar
- narf
- blarg
- point
tasks:
- set_fact:
myfact: "{{ myfact | default([]) }} + ['{{ item }}']"
with_items: "{{ foo }}"
- debug:
msg: "{{ myfact }}"
EXPECTED RESULTS
TASK [debug] *******************************************************************
ok: [localhost] => {
"msg": [
"bar",
"narf",
"blarg",
"point"
]
}
ACTUAL RESULTS
TASK [debug] *******************************************************************
ok: [localhost] => {
"msg": [
"point"
]
}