Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Included role is erroneously skipped, when the including role depends on another role whose unrelated dependency is skipped #23379

Closed
eerorika opened this issue Apr 6, 2017 · 3 comments
Assignees
Labels
affects_2.2 This issue/PR affects Ansible v2.2 bug This issue/PR relates to a bug. include_role support:core This issue/PR relates to code supported by the Ansible Engineering Team.

Comments

@eerorika
Copy link

eerorika commented Apr 6, 2017

ISSUE TYPE
  • Bug Report
COMPONENT NAME

include_role

ANSIBLE VERSION
ansible 2.2.2.0
  config file = 
  configured module search path = Default w/o overrides
CONFIGURATION
OS / ENVIRONMENT

N/A

SUMMARY

Included role is erroneously skipped, when the including role depends on another role whose unrelated dependency is skipped.

Since test_3 is included unconditionally, and the skipped dependency is unrelated, test_3 shouldn't be skipped, but it is.

I get expected output if

  • The condition of the test_2 -> test_4 dependency is True.
  • Or the test_2 -> test_4 dependency is removed.
  • Or the test_1 -> test_2 dependency is removed.
STEPS TO REPRODUCE
tail  **/*.yml
==> roles/test_1/meta/main.yml <==
---
dependencies:
  - test_2

==> roles/test_1/tasks/main.yml <==
---
- include_role:
    name: test_3

==> roles/test_2/meta/main.yml <==
---
dependencies:
  - {
    role: test_4, # conditional dependency
    when: no      # whose condition evaluates to False
  }

==> roles/test_3/tasks/main.yml <==
---
- debug:
    msg: 3

==> roles/test_4/tasks/main.yml <==
---

==> test.yml <==
---
- hosts: all
  roles:
    - test_1
ansible-playbook -vvvv -i "localhost," -c local test.yml
EXPECTED RESULTS
TASK [test_3 : debug] **********************************************************
ok: [localhost] => {
    "msg": 3
}
ACTUAL RESULTS
No config file found; using defaults
Set default localhost to localhost
Loading callback plugin default of type stdout, v2.0 from /usr/lib64/python2.7/site-packages/ansible/plugins/callback/__init__.pyc

PLAYBOOK: test.yml *************************************************************
1 plays in test.yml

PLAY [all] *********************************************************************

TASK [setup] *******************************************************************
Using module file /usr/lib64/python2.7/site-packages/ansible/modules/core/system/setup.py
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: usr
<localhost> EXEC /bin/sh -c 'echo ~ && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/usr/.ansible/tmp/ansible-tmp-1491519674.09-105434180556369 `" && echo ansible-tmp-1491519674.09-105434180556369="` echo /home/usr/.ansible/tmp/ansible-tmp-1491519674.09-105434180556369 `" ) && sleep 0'
<localhost> PUT /tmp/tmp_f8MiY TO /home/usr/.ansible/tmp/ansible-tmp-1491519674.09-105434180556369/setup.py
<localhost> EXEC /bin/sh -c 'chmod u+x /home/usr/.ansible/tmp/ansible-tmp-1491519674.09-105434180556369/ /home/usr/.ansible/tmp/ansible-tmp-1491519674.09-105434180556369/setup.py && sleep 0'
<localhost> EXEC /bin/sh -c '/usr/bin/python /home/usr/.ansible/tmp/ansible-tmp-1491519674.09-105434180556369/setup.py; rm -rf "/home/usr/.ansible/tmp/ansible-tmp-1491519674.09-105434180556369/" > /dev/null 2>&1 && sleep 0'
ok: [localhost]

TASK [test_3 : debug] **********************************************************
task path: /home/eero/PycharmProjects/ansible_test/roles/test_3/tasks/main.yml:2
skipping: [localhost] => {
    "changed": false, 
    "skip_reason": "Conditional check failed", 
    "skipped": true
}

PLAY RECAP *********************************************************************
localhost                  : ok=1    changed=0    unreachable=0    failed=0 
@ansibot ansibot added affects_2.2 This issue/PR affects Ansible v2.2 bug_report module This issue/PR relates to a module. needs_triage Needs a first human triage before being processed. labels Apr 6, 2017
@eerorika
Copy link
Author

eerorika commented Apr 8, 2017

For what it's worth, I wrote a unit test for this: test_include_role_deps.py

@mario-pranjic
Copy link

Hi,

Any feedback on this bug?

@ansibot ansibot added the support:core This issue/PR relates to code supported by the Ansible Engineering Team. label Jun 29, 2017
@ansibot ansibot removed the module This issue/PR relates to a module. label Nov 17, 2017
@ansibot ansibot added bug This issue/PR relates to a bug. and removed bug_report labels Mar 1, 2018
@bcoca bcoca added this to Pending in include and import issues Apr 17, 2018
@sivel
Copy link
Member

sivel commented Apr 27, 2018

This issue was resolved in eeaa676 and included in the v2.3.2 release

If you have further questions please stop by IRC or the mailing list:

@sivel sivel closed this as completed Apr 27, 2018
include and import issues automation moved this from Pending to Done Apr 27, 2018
@ansible ansible locked and limited conversation to collaborators Apr 29, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.2 This issue/PR affects Ansible v2.2 bug This issue/PR relates to a bug. include_role support:core This issue/PR relates to code supported by the Ansible Engineering Team.
Projects
Development

No branches or pull requests

7 participants