# with\_items and default filter with empty list not working in ansible 1.8.1

**URL:** <https://forum.ansible.com/t/with-items-and-default-filter-with-empty-list-not-working-in-ansible-1-8-1/16921>\
**Category:** Ansible Project\
**Created:** [November 30, 2014, 5:33pm UTC](https://forum.ansible.com/t/with-items-and-default-filter-with-empty-list-not-working-in-ansible-1-8-1/16921 "2014-11-30T17:33:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![parnigot](https://avatars.discourse-cdn.com/v4/letter/p/e480ec/32.png) [@parnigot](https://forum.ansible.com/u/parnigot)\
**Post date:** [November 30, 2014, 5:33pm UTC](https://forum.ansible.com/t/with-items-and-default-filter-with-empty-list-not-working-in-ansible-1-8-1/16921/1 "2014-11-30T17:33:51Z")

</div>

Hello guys,

I’ve recently updated ansible to v1.8.1 and I’m having some issues with some playbooks that worked on older ansible versions.

For example I’ve a reusable role that manages the installation of packages with the following task:

- name: Install additional packages  
apt: name={{ item }} update\_cache=yes  
with\_items: additional\_packages|default()

Where the variable additional\_packages is usually not defined, but can be set on a per host or per group base.  
On older versions this worked as expected:

- if additional\_packages is not defined, default to an empty list and skip the task
- if additional\_packages is defined, install the packages in the list

Now in v1.8.1 I get the following error:

TASK: [pkgs | Install additional packages] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
fatal: [hal9000] =\> with\_items expects a list or a set

FATAL: all hosts have already failed – aborting

Was this an intended change or is it a bug?

Best regards,  
EP

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [November 30, 2014, 6:08pm UTC](https://forum.ansible.com/t/with-items-and-default-filter-with-empty-list-not-working-in-ansible-1-8-1/16921/2 "2014-11-30T18:08:19Z")

</div>

we have a known issue with templating in lookup plugins (with\_\<lookup  
plugin), for now try using explicit templating with\_items:  
"{{additional\_packages|default()}}"
