{"action":"created","issue":{"url":"https://api.github.com/repos/ansible/ansible/issues/38991","repository_url":"https://api.github.com/repos/ansible/ansible","labels_url":"https://api.github.com/repos/ansible/ansible/issues/38991/labels{/name}","comments_url":"https://api.github.com/repos/ansible/ansible/issues/38991/comments","events_url":"https://api.github.com/repos/ansible/ansible/issues/38991/events","html_url":"https://github.com/ansible/ansible/issues/38991","id":315717126,"node_id":"MDU6SXNzdWUzMTU3MTcxMjY=","number":38991,"title":"set_fact in with_items append loop only keeps last item","user":{"login":"lae","id":1318013,"node_id":"MDQ6VXNlcjEzMTgwMTM=","avatar_url":"https://avatars3.githubusercontent.com/u/1318013?v=4","gravatar_id":"","url":"https://api.github.com/users/lae","html_url":"https://github.com/lae","followers_url":"https://api.github.com/users/lae/followers","following_url":"https://api.github.com/users/lae/following{/other_user}","gists_url":"https://api.github.com/users/lae/gists{/gist_id}","starred_url":"https://api.github.com/users/lae/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lae/subscriptions","organizations_url":"https://api.github.com/users/lae/orgs","repos_url":"https://api.github.com/users/lae/repos","events_url":"https://api.github.com/users/lae/events{/privacy}","received_events_url":"https://api.github.com/users/lae/received_events","type":"User","site_admin":false},"labels":[{"id":686214011,"node_id":"MDU6TGFiZWw2ODYyMTQwMTE=","url":"https://api.github.com/repos/ansible/ansible/labels/affects_2.5","name":"affects_2.5","color":"ededed","default":false},{"id":785271699,"node_id":"MDU6TGFiZWw3ODUyNzE2OTk=","url":"https://api.github.com/repos/ansible/ansible/labels/bug","name":"bug","color":"fbca04","default":true},{"id":496359346,"node_id":"MDU6TGFiZWw0OTYzNTkzNDY=","url":"https://api.github.com/repos/ansible/ansible/labels/module","name":"module","color":"1d76db","default":false},{"id":383076471,"node_id":"MDU6TGFiZWwzODMwNzY0NzE=","url":"https://api.github.com/repos/ansible/ansible/labels/python3","name":"python3","color":"fbca04","default":false},{"id":636352796,"node_id":"MDU6TGFiZWw2MzYzNTI3OTY=","url":"https://api.github.com/repos/ansible/ansible/labels/support:core","name":"support:core","color":"ededed","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":7,"created_at":"2018-04-19T03:41:26Z","updated_at":"2018-11-19T21:01:33Z","closed_at":"2018-04-19T11:22:47Z","author_association":"CONTRIBUTOR","body":"##### ISSUE TYPE\r\n - Bug Report\r\n\r\n##### COMPONENT NAME\r\nset_fact\r\n\r\n##### ANSIBLE VERSION\r\n```\r\nansible 2.5.1\r\n  config file = /home/lae/.ansible.cfg\r\n  configured module search path = ['/home/lae/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']\r\n  ansible python module location = /home/lae/.virtualenvs/ansible-2.5.1/lib/python3.6/site-packages/ansible\r\n  executable location = /home/lae/.virtualenvs/ansible-2.5.1/bin/ansible\r\n  python version = 3.6.5 (default, Apr 12 2018, 22:45:43) [GCC 7.3.1 20180312]\r\n```\r\nBreaking commit appears to be 663400b504baa706c9136c13c990ed447c00a364 \r\n\r\n##### CONFIGURATION\r\n\r\n```\r\nANSIBLE_SSH_CONTROL_PATH(/home/lae/.ansible.cfg) = %(directory)s/%%h-%%r\r\nHOST_KEY_CHECKING(/home/lae/.ansible.cfg) = False\r\n```\r\n\r\n##### OS / ENVIRONMENT\r\n\r\nN/A\r\n\r\n##### SUMMARY\r\n\r\nWhen attempting to initialize and populate a new list fact when looping over a different list, it only populates it with the last item.\r\n\r\n##### STEPS TO REPRODUCE\r\n\r\nExecute the following playbook:\r\n\r\n```yaml\r\n---\r\n- hosts: localhost\r\n  connection: local\r\n  tasks:\r\n    - set_fact:\r\n        some_list: \"{{ some_list | default([]) | union([item]) }}\"\r\n      with_items:\r\n        - hello\r\n        - new\r\n        - world\r\n    - debug:\r\n        var: some_list\r\n```\r\n\r\nAbove's a minimal example, but this has broken the role I use for CI against roles that involve multiple hosts (like VM clustering).\r\n\r\nTask:\r\nhttps://github.com/lae/ansible-role-travis-lxc/blob/dbd6553300c710e815dc32829de5d597b7173cc1/tasks/main.yml#L110\r\nOutput:\r\nhttps://travis-ci.org/lae/ansible-role-proxmox/jobs/368444560#L2042\r\n\r\n##### EXPECTED RESULTS\r\n```\r\nPLAY [all] ****************************************************************\r\n\r\nTASK [Gathering Facts] ****************************************************\r\nok: [localhost]\r\n\r\nTASK [set_fact] ***********************************************************\r\nok: [localhost] => (item=hello)\r\nok: [localhost] => (item=new)\r\nok: [localhost] => (item=world)\r\n\r\nTASK [debug] **************************************************************\r\nok: [localhost] => {\r\n    \"some_list\": [\r\n        \"hello\",\r\n        \"new\",\r\n        \"world\"\r\n    ]\r\n}\r\n\r\nPLAY RECAP ****************************************************************\r\nlocalhost                  : ok=3    changed=0    unreachable=0    failed=0\r\n```\r\n\r\n##### ACTUAL RESULTS\r\n\r\n```\r\nPLAY [all] ****************************************************************\r\n\r\nTASK [Gathering Facts] ****************************************************\r\nok: [localhost]\r\n\r\nTASK [set_fact] ***********************************************************\r\nok: [localhost] => (item=hello)\r\nok: [localhost] => (item=new)\r\nok: [localhost] => (item=world)\r\n\r\nTASK [debug] **************************************************************\r\nok: [localhost] => {\r\n    \"some_list\": [\r\n        \"world\"\r\n    ]\r\n}\r\n\r\nPLAY RECAP ****************************************************************\r\nlocalhost                  : ok=3    changed=0    unreachable=0    failed=0\r\n```\r\n\r\nCommand run:\r\n```sh\r\nansible-playbook -i localhost, unionized_list.yml\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/ansible/ansible/issues/comments/440040246","html_url":"https://github.com/ansible/ansible/issues/38991#issuecomment-440040246","issue_url":"https://api.github.com/repos/ansible/ansible/issues/38991","id":440040246,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0MDA0MDI0Ng==","user":{"login":"drewmullen","id":3812162,"node_id":"MDQ6VXNlcjM4MTIxNjI=","avatar_url":"https://avatars1.githubusercontent.com/u/3812162?v=4","gravatar_id":"","url":"https://api.github.com/users/drewmullen","html_url":"https://github.com/drewmullen","followers_url":"https://api.github.com/users/drewmullen/followers","following_url":"https://api.github.com/users/drewmullen/following{/other_user}","gists_url":"https://api.github.com/users/drewmullen/gists{/gist_id}","starred_url":"https://api.github.com/users/drewmullen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/drewmullen/subscriptions","organizations_url":"https://api.github.com/users/drewmullen/orgs","repos_url":"https://api.github.com/users/drewmullen/repos","events_url":"https://api.github.com/users/drewmullen/events{/privacy}","received_events_url":"https://api.github.com/users/drewmullen/received_events","type":"User","site_admin":false},"created_at":"2018-11-19T21:01:33Z","updated_at":"2018-11-19T21:01:33Z","author_association":"NONE","body":"why was this issue closed? appears to still be broken"}}
{"actor":{"display_login":"drewmullen"}}