8000 Apparent 2.5.1 regression -- Appending to lists or strings in with_items loops is broken · Issue #39234 · ansible/ansible · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Apparent 2.5.1 regression -- Appending to lists or strings in with_items loops is broken #39234
Closed
@dustinblack

Description

@dustinblack
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"
   ]
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    affects_2.5This issue/PR affects Ansible v2.5bugThis issue/PR relates to a bug.support:coreThis issue/PR relates to code supported by the Ansible Engineering Team.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0