# An included role is incorrectly skipped when an earlier dependency is skipped

**URL:** <https://forum.ansible.com/t/an-included-role-is-incorrectly-skipped-when-an-earlier-dependency-is-skipped/24053>\
**Category:** Ansible Project\
**Created:** [March 24, 2017, 6:37am UTC](https://forum.ansible.com/t/an-included-role-is-incorrectly-skipped-when-an-earlier-dependency-is-skipped/24053 "2017-03-24T06:37:03Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![asavtch](https://avatars.discourse-cdn.com/v4/letter/a/ecd19e/32.png) [@asavtch](https://forum.ansible.com/u/asavtch)\
**Post date:** [March 24, 2017, 6:37am UTC](https://forum.ansible.com/t/an-included-role-is-incorrectly-skipped-when-an-earlier-dependency-is-skipped/24053/1 "2017-03-24T06:37:03Z")

</div>

Ansible 2.2.1.0  
Configuration: one role (sample role) has a dependency (dep\_role) and an included role (common)

The files:

$ find -type f  
./playbook.yml  
./roles/common/tasks/main.yml  
./roles/dep\_role/tasks/main.yml  
./roles/sample\_role/meta/main.yml  
./roles/sample\_role/tasks/main.yml  
$

$ cat playbook.yml

- hosts: localhost  
roles:
- sample\_role  
$

$ cat roles/common/tasks/main.yml

- debug: msg=“common role”  
$

$ cat roles/dep\_role/tasks/main.yml

- debug: msg=“dependency role”  
$

$ cat roles/sample\_role/meta/main.yml  
dependencies:

- {role: dep\_role,  
when: False}

$ cat roles/sample\_role/tasks/main.yml

- debug: msg=“sample role”

- name: run common role  
include\_role:  
name: common  
$

The result:

$ ansible-playbook playbook.yml  
[WARNING]: provided hosts list is empty, only localhost is available

PLAY [localhost] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

TASK [setup] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [localhost]

TASK [dep\_role : debug] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
skipping: [localhost]

TASK [sample\_role : debug] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [localhost] =\> {  
“msg”: “sample role”  
}

TASK [common : debug] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
skipping: [localhost]

PLAY RECAP \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
localhost : ok=2 changed=0 unreachable=0 failed=0

$

Seems like the false condition of the dependency is incorrectly applied to the included role too. If the condition of the dependency is true, the included role runs as expected:

ansible-playbook playbook.yml  
[WARNING]: provided hosts list is empty, only localhost is available

PLAY [localhost] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

TASK [setup] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [localhost]

TASK [dep\_role : debug] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [localhost] =\> {  
“msg”: “dependency role”  
}

TASK [sample\_role : debug] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [localhost] =\> {  
“msg”: “sample role”  
}

TASK [common : debug] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [localhost] =\> {  
“msg”: “common role”  
}

PLAY RECAP \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
localhost : ok=4 changed=0 unreachable=0 failed=0
