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

include_role: causing subsequent dependencies to run more than once. #24326

Closed
rahul-dhumal opened this issue May 5, 2017 · 5 comments
Closed
Labels
affects_2.2 This issue/PR affects Ansible v2.2 bug This issue/PR relates to a bug. c:playbook/role_include include_role module This issue/PR relates to a module. support:core This issue/PR relates to code supported by the Ansible Engineering Team.

Comments

@rahul-dhumal
Copy link

ISSUE TYPE
  • Bug Report
COMPONENT NAME

include_role:

ANSIBLE VERSION

ansible 2.2.0.0
config file = ../playbooks/ansible.cfg
configured module search path = Default w/o overrides

CONFIGURATION

No changes in ansible configuration file

OS / ENVIRONMENT

Ubuntu 16.04

SUMMARY

When include_role: is used (specifically at the end of a .yml) file, it causes that yml file to run repeatedly more than once in all subsequent dependencies.

STEPS TO REPRODUCE

ansible-reported-bug.zip

Attached some sample roles/playbooks which will reproduce the scenario -

  1. Unzip the include_role-bug.zip
  2. run playbook main_calling.yml >>> ansible-playbook main-calling.yml
DEPENDENCIES IN ATTACHED SAMPLE

-main-calling.yml [Main playbook to run]
- includes [common-test-role]
              - [common-test-role] includes role - [common-role-includes-this-another-role] this causes the problem
- includes another role as [first-role-dependent-on-common-test-role] which internally depends on [common-test-role] so common-test-role is running twice when include_role is used inside [common-test-role] at the end, not anywhere else [i.e. in the beginning or in the middle]

To Summarize :
Tasks directly inside common-test-role are executed twice when include_role: some_role is the last line

EXPECTED RESULTS
PLAY [localhost] ***************************************************************

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

TASK [common-test-role : debug] ************************************************
ok: [localhost] => {
    "msg": "step 1 - first inner task of common-test-role"
}

TASK [common-test-role : debug] ************************************************
ok: [localhost] => {
    "msg": "step 2 - second inner task of common-test-role"
}

TASK [just-another-role-to-reflect-internal-dependecy : debug] *****************
ok: [localhost] => {
    "msg": "step 3 - inner task of just-another-role-to-reflect-internal-dependecy [this would be displayed when common-test-role hits include_role]"
}

TASK [first-role-dependent-on-common-test-role : debug] ************************
ok: [localhost] => {
    "msg": "step 4 inside inner task of first-role-dependent-on-common-test-role"
}

PLAY RECAP *********************************************************************
localhost                  : ok=7    changed=0    unreachable=0    failed=0   

ACTUAL RESULTS
PLAY [localhost] ***************************************************************

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

TASK [common-test-role : debug] ************************************************
ok: [localhost] => {
    "msg": "step 1 - first inner task of common-test-role"
}

TASK [common-test-role : debug] ************************************************
ok: [localhost] => {
    "msg": "step 2 - second inner task of common-test-role"
}

TASK [just-another-role-to-reflect-internal-dependecy : debug] *****************
ok: [localhost] => {
    "msg": "step 3 - inner task of just-another-role-to-reflect-internal-dependecy [this would be displayed when common-test-role hits include_role]"
}

TASK [common-test-role : debug] ************************************************
ok: [localhost] => {
    "msg": "step 1 - first inner task of common-test-role"
}

TASK [common-test-role : debug] ************************************************
ok: [localhost] => {
    "msg": "step 2 - second inner task of common-test-role"
}

TASK [first-role-dependent-on-common-test-role : debug] ************************
ok: [localhost] => {
    "msg": "step 4 inside inner task of first-role-dependent-on-common-test-role"
}

PLAY RECAP *********************************************************************
localhost                  : ok=7    changed=0    unreachable=0    failed=0   

TASK: setup ------------------------------------------------------------- 0.40s
TASK: common-test-role : debug ------------------------------------------ 0.02s
TASK: first-role-dependent-on-common-test-role : debug ------------------ 0.02s
TASK: just-another-role-to-reflect-internal-dependecy : debug ----------- 0.02s
TASK: common-test-role : debug ------------------------------------------ 0.01s
TASK: common-test-role : debug ------------------------------------------ 0.01s
TASK: common-test-role : debug ------------------------------------------ 0.01s

Playbook finished: Fri May  5 14:20:33 2017, 7 total tasks.  0:00:00 elapsed. 


@ansibot ansibot added affects_2.2 This issue/PR affects Ansible v2.2 bug_report needs_triage Needs a first human triage before being processed. labels May 5, 2017
@jctanner
Copy link
Contributor

jctanner commented May 5, 2017

@rahul-dhumal does this force the behavior you expect?

  4 - include_role:
  5     name: common-role-includes-this-another-role
  6     allow_duplicates: no 

needs_info

@jctanner jctanner added c:playbook/role_include and removed needs_triage Needs a first human triage before being processed. labels May 5, 2017
@ansibot ansibot added the needs_info This issue requires further information. Please answer any outstanding questions. label May 5, 2017
@rahul-dhumal
Copy link
Author

I believe allow_duplicates has default value set to no so this may not work, anyways, I will try once again by explicitly setting it to 'no' & keep you posted here.

@ansibot ansibot removed the needs_info This issue requires further information. Please answer any outstanding questions. label May 5, 2017
@rahul-dhumal
Copy link
Author

Tried this but as mentioned earlier, it did not work!

- include_role:
	name: common-role-includes-this-another-role
	allow_duplicates: no 

@lhoss
Copy link

lhoss commented May 15, 2017

probably relates to #18748 ( and dupe: #21279 )

@ansibot ansibot added the support:core This issue/PR relates to code supported by the Ansible Engineering Team. label Jun 29, 2017
@ansibot ansibot added the module This issue/PR relates to a module. label Feb 14, 2018
@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 ef96329 and included in the v2.4.1 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. c:playbook/role_include include_role module This issue/PR relates to a module. support:core This issue/PR relates to code supported by the Ansible Engineering Team.
Projects
Development

No branches or pull requests

6 participants