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

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