# fatal error when skipping includes

**URL:** <https://forum.ansible.com/t/fatal-error-when-skipping-includes/19013>\
**Category:** Ansible Project\
**Created:** [August 13, 2015, 10:55pm UTC](https://forum.ansible.com/t/fatal-error-when-skipping-includes/19013 "2015-08-13T22:55:05Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![senorsmile](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/senorsmile/32/9024_2.png) [@senorsmile](https://forum.ansible.com/u/senorsmile)\
**Post date:** [August 13, 2015, 10:55pm UTC](https://forum.ansible.com/t/fatal-error-when-skipping-includes/19013/1 "2015-08-13T22:55:05Z")

</div>

Error:  
`  
fatal: [myhost] =\> with\_items expects a list or a set

`

I have a role with the following tasks(snippets included):  
tasks/main.yml  
`

---

<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:** [August 14, 2015, 12:22am UTC](https://forum.ansible.com/t/fatal-error-when-skipping-includes/19013/2 "2015-08-14T00:22:29Z")

</div>

the include itself is not skippable, the when gets added to the included tasks.

---

<div class="post-metadata">

**Author:** ![senorsmile](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/senorsmile/32/9024_2.png) [@senorsmile](https://forum.ansible.com/u/senorsmile)\
**Post date:** [August 14, 2015, 12:26am UTC](https://forum.ansible.com/t/fatal-error-when-skipping-includes/19013/3 "2015-08-14T00:26:57Z")

</div>

I’m not sure I follow you. The include is being skipped since the when: condition isn’t met. All other tasks above the one that errs out shows skipped. It’s just that specific task that makes everything fail for that host.

I have attempted to add a ‘default’ filter to the when:, but it seems like it is always defined, even though it’s being skipped ?!?!?

---

<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:** [August 14, 2015, 12:46am UTC](https://forum.ansible.com/t/fatal-error-when-skipping-includes/19013/4 "2015-08-14T00:46:03Z")

</div>

try:  
&nbsp;&nbsp;with\_items: "{{ ((the\_files|default()).stdout\_lines|default()) | list }}"

---

<div class="post-metadata">

**Author:** ![senorsmile](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/senorsmile/32/9024_2.png) [@senorsmile](https://forum.ansible.com/u/senorsmile)\
**Post date:** [August 14, 2015, 1:09am UTC](https://forum.ansible.com/t/fatal-error-when-skipping-includes/19013/5 "2015-08-14T01:09:06Z")

</div>

Ah, great catch. That actually works.

Now, to convince ansible not to evaluate anything in included files which are skipped…

---

<div class="post-metadata">

**Author:** ![senorsmile](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/senorsmile/32/9024_2.png) [@senorsmile](https://forum.ansible.com/u/senorsmile)\
**Post date:** [August 19, 2015, 4:47pm UTC](https://forum.ansible.com/t/fatal-error-when-skipping-includes/19013/6 "2015-08-19T16:47:04Z")

</div>

And I’ve run into this bug yet again!

I have the following which fails on skipped hosts:

`

- name: Check all other host certs  
connection: local  
sudo: false  
stat:  
path: “{{ role\_path }}/templates/ca/{{ item }}.crt”  
with\_items: “{{ (nagios\_host\_fqdns\_flat|default()).split(‘,’)|default() }}”

register: stat\_host\_certs

`

This is becoming quite time consuming to insert for every with\_\* on skipped files!!!

---

<div class="post-metadata">

**Author:** ![senorsmile](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/senorsmile/32/9024_2.png) [@senorsmile](https://forum.ansible.com/u/senorsmile)\
**Post date:** [August 19, 2015, 5:02pm UTC](https://forum.ansible.com/t/fatal-error-when-skipping-includes/19013/7 "2015-08-19T17:02:30Z")

</div>

@Brian,

According to your comment in this issue:  
[https://github.com/ansible/ansible/issues/11961](https://github.com/ansible/ansible/issues/11961)

the when: of the include: gets run AFTER the with\_xxx of the child file? This doesn’t make any sense to me. If you are conditionally including a file, NOTHING in that file should be processed. I am not being combative, but am I missing something here? That seems like a real bug; the specific bug that I’m running into over and over again.

---

<div class="post-metadata">

**Author:** ![Serge\_van\_Ginderacht](https://avatars.discourse-cdn.com/v4/letter/s/b782af/32.png) [@Serge\_van\_Ginderacht](https://forum.ansible.com/u/Serge_van_Ginderacht)\
**Post date:** [August 19, 2015, 5:09pm UTC](https://forum.ansible.com/t/fatal-error-when-skipping-includes/19013/8 "2015-08-19T17:09:07Z")

</div>

​You are not conditionally including. you are applying the condition to all  
tasks in the include.

​

---

<div class="post-metadata">

**Author:** ![senorsmile](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/senorsmile/32/9024_2.png) [@senorsmile](https://forum.ansible.com/u/senorsmile)\
**Post date:** [August 19, 2015, 5:20pm UTC](https://forum.ansible.com/t/fatal-error-when-skipping-includes/19013/9 "2015-08-19T17:20:37Z")

</div>

Ahhhh! Thanks Serge. So it is applying in the same manner as roles apply args (e.g. tags: ).

So, now to figure out how to default a split().

---

<div class="post-metadata">

**Author:** ![senorsmile](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/senorsmile/32/9024_2.png) [@senorsmile](https://forum.ansible.com/u/senorsmile)\
**Post date:** [August 19, 2015, 9:08pm UTC](https://forum.ansible.com/t/fatal-error-when-skipping-includes/19013/10 "2015-08-19T21:08:10Z")

</div>

Ultimately fixed this by simply putting this into the role’s defaults/main.yml

`  
nagios\_host\_fqdns\_flat: ()

`
