# Feedback after " include/include\_role: maximum recursion depth exceeded #23609" as been closed

**URL:** <https://forum.ansible.com/t/feedback-after-include-include-role-maximum-recursion-depth-exceeded-23609-as-been-closed/26435>\
**Category:** Ansible Developer\
**Created:** [January 7, 2018, 5:43pm UTC](https://forum.ansible.com/t/feedback-after-include-include-role-maximum-recursion-depth-exceeded-23609-as-been-closed/26435 "2018-01-07T17:43:45Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Remi\_Ferrand](https://avatars.discourse-cdn.com/v4/letter/r/5fc32e/32.png) [@Remi\_Ferrand](https://forum.ansible.com/u/Remi_Ferrand)\
**Post date:** [January 7, 2018, 5:43pm UTC](https://forum.ansible.com/t/feedback-after-include-include-role-maximum-recursion-depth-exceeded-23609-as-been-closed/26435/1 "2018-01-07T17:43:45Z")

</div>

As requested by James Cammarata at the end of the github issue “[include/include\_role: maximum recursion depth exceeded](https://github.com/ansible/ansible/issues/23609)”, I’m posting my feedback at the _ansible-devel_ list.

I’ve tested the patched version of ansible with [this stupid playbook](https://github.com/riton/ansible_POC_include_role_max_recursion_depth_issue_23609) that emulates a useless chain of roles that include each other using **include\_role** (r1 → include r2 that includes r3 that includes r4 … and so on).  
With the patched version, my proof of concept now successfully runs with **26** roles that include each other when it was merely impossible to use before that patch.

If I emulate more roles (_just for fun_) that include each other in a chained manner, the bug still occurs after **27** included roles. This is quite a huge number that allows me to say that I can now start to use the **include\_role** statement in our site production playbooks. Thanks for work guys !

Another thing I’ve noticed is the fact that ansible becomes very slow the more role I chain. When it comes to something like the 18th role included, it take something like 5 seconds to just print the debug message of the next role and go on. For the next included role, it goes even slower and so on…  
When it comes to unstack the roles and print the “after include\_role” debug statement, this goes blazingly fast.

That’s all for my feedback.

Again, thanks for the work guys.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [January 10, 2018, 12:03am UTC](https://forum.ansible.com/t/feedback-after-include-include-role-maximum-recursion-depth-exceeded-23609-as-been-closed/26435/2 "2018-01-10T00:03:52Z")

</div>

Have you tested with import\_role? Since it runs at 'static' it should  
show a very different profile than the 'dynamic' include\_role.

---

<div class="post-metadata">

**Author:** ![Remi\_Ferrand](https://avatars.discourse-cdn.com/v4/letter/r/5fc32e/32.png) [@Remi\_Ferrand](https://forum.ansible.com/u/Remi_Ferrand)\
**Post date:** [January 10, 2018, 8:13am UTC](https://forum.ansible.com/t/feedback-after-include-include-role-maximum-recursion-depth-exceeded-23609-as-been-closed/26435/3 "2018-01-10T08:13:03Z")

</div>

Indeed it shows a very different profile.

I’ve just tested and updated my [POC playbook](https://github.com/riton/ansible_POC_include_role_max_recursion_depth_issue_23609#using-import_role) to use **import\_role** and do the same test.

Here is the result using **8** _chained/nested roles_:  
``

```auto
$ ansible-playbook import_role.yml
[...]
PLAY [localhost] ***************************************************************************************************************************

TASK [import_r1 : debug] *******************************************************************************************************************
ok: [localhost] => {
    "attempts": 1, 
    "msg": "Start of import_r1"
}

TASK [import_r2 : debug] *******************************************************************************************************************
ok: [localhost] => {
    "attempts": 1, 
    "msg": "Start of import_r2"
}

TASK [import_r3 : debug] *******************************************************************************************************************
ok: [localhost] => {
    "attempts": 1, 
    "msg": "Start of import_r3"
}

TASK [import_r4 : debug] *******************************************************************************************************************
ok: [localhost] => {
    "attempts": 1, 
    "msg": "Start of import_r4"
}

TASK [import_r5 : debug] *******************************************************************************************************************
ok: [localhost] => {
    "attempts": 1, 
    "msg": "Start of import_r5"
}

TASK [import_r6 : debug] *******************************************************************************************************************
ok: [localhost] => {
    "attempts": 1, 
    "msg": "Start of import_r6"
}

TASK [import_r7 : debug] *******************************************************************************************************************
ok: [localhost] => {
    "attempts": 1, 
    "msg": "Start of import_r7"
}
ERROR! Unexpected Exception, this is probably a bug: maximum recursion depth exceeded
to see the full traceback, use -vvv

```

I’m still using the latest **devel** ansible version in my tests.

It seems that the **import\_role** is triggering the bug even sooner than **include\_role** does.

Cheers

Rémi

---

<div class="post-metadata">

**Author:** ![Remi\_Ferrand](https://avatars.discourse-cdn.com/v4/letter/r/5fc32e/32.png) [@Remi\_Ferrand](https://forum.ansible.com/u/Remi_Ferrand)\
**Post date:** [February 21, 2018, 9:58pm UTC](https://forum.ansible.com/t/feedback-after-include-include-role-maximum-recursion-depth-exceeded-23609-as-been-closed/26435/4 "2018-02-21T21:58:14Z")

</div>

Another update on this thread after [Matt Martz](https://github.com/sivel) update on the [Gihub issue #23609](https://github.com/ansible/ansible/issues/23609).

The merge of [https://github.com/ansible/ansible/pull/36470](https://github.com/ansible/ansible/pull/36470) indeed solved the whole ` **include_role** ` problem and everything is now working fast and as expected.  
Thanks to everyone that has spent time working on this !

The problem with ` **import_role** ` seems to be always present and still makes it difficult to use in production.

I’ve updated my [proof-of-concept](https://github.com/riton/ansible_POC_include_role_max_recursion_depth_issue_23609) that easily allows one to trigger the ` **import_role** ` bug accordingly.
