<h5 dir="auto">ISSUE TYPE</h5>

<ul dir="auto">
<li>Bug Report</li>
</ul>
<h5 dir="auto">COMPONENT NAME</h5>


<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="ansible 2.4.2.0
  config file = /Users/mdelagrange/.ansible.cfg
  configured module search path = [u'/Users/mdelagrange/src/ops/ansible/library']
  ansible python module location = /Users/mdelagrange/src/github/ansible_include_role_bug/env/lib/python2.7/site-packages/ansible
  executable location = ./env/bin/ansible
  python version = 2.7.12 (default, Jun 29 2016, 14:05:02) [GCC 4.2.1 Compatible Apple LLVM 7.3.0 (clang-703.0.31)]"><pre class="notranslate"><code class="notranslate">ansible 2.4.2.0
  config file = /Users/mdelagrange/.ansible.cfg
  configured module search path = [u'/Users/mdelagrange/src/ops/ansible/library']
  ansible python module location = /Users/mdelagrange/src/github/ansible_include_role_bug/env/lib/python2.7/site-packages/ansible
  executable location = ./env/bin/ansible
  python version = 2.7.12 (default, Jun 29 2016, 14:05:02) [GCC 4.2.1 Compatible Apple LLVM 7.3.0 (clang-703.0.31)]
</code></pre></div>
<h5 dir="auto">CONFIGURATION</h5>

<p dir="auto">ANSIBLE_SSH_CONTROL_PATH(/Users/mdelagrange/.ansible.cfg) = %(directory)s/%%h-%%<br>
DEFAULT_HOST_LIST(/Users/mdelagrange/.ansible.cfg) = [u'/Users/mdelagrange/src/o<br>
DEFAULT_MODULE_PATH(/Users/mdelagrange/.ansible.cfg) = [u'/Users/mdelagrange/src<br>
DEFAULT_VAULT_PASSWORD_FILE(/Users/mdelagrange/.ansible.cfg) = /Users/mdelagrang<br>
HOST_KEY_CHECKING(/Users/mdelagrange/.ansible.cfg) = False</p>
<h5 dir="auto">OS / ENVIRONMENT</h5>

<p dir="auto">OS X</p>
<h5 dir="auto">SUMMARY</h5>

<p dir="auto">The "include_role" task seems to result in infinite recursion.</p>
<h5 dir="auto">STEPS TO REPRODUCE</h5>

<ol dir="auto">
<li>Clone <a href="https://github.com/mdelagrange/ansible_include_role_bug">https://github.com/mdelagrange/ansible_include_role_bug</a></li>
<li>Run <code class="notranslate">make test_2_4_2_0</code></li>
</ol>

<div class="highlight highlight-source-yaml notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="- hosts: localhost
  roles:
    - test_role
  post_tasks:
    - include_role:
        name: test_role"><pre class="notranslate">- <span class="pl-ent">hosts</span>: <span class="pl-s">localhost</span>
  <span class="pl-ent">roles</span>:
    - <span class="pl-s">test_role</span>
  <span class="pl-ent">post_tasks</span>:
    - <span class="pl-ent">include_role</span>:
        <span class="pl-ent">name</span>: <span class="pl-s">test_role</span></pre></div>

<h5 dir="auto">EXPECTED RESULTS</h5>

<p dir="auto">test_role is executed twice.</p>
<h5 dir="auto">ACTUAL RESULTS</h5>


<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="ansible-playbook 2.4.2.0
  config file = /Users/mdelagrange/.ansible.cfg
  configured module search path = [u'/Users/mdelagrange/src/ops/ansible/library']
  ansible python module location = /Users/mdelagrange/src/github/ansible_include_role_bug/env/lib/python2.7/site-packages/ansible
  executable location = ./env/bin/ansible-playbook
  python version = 2.7.12 (default, Jun 29 2016, 14:05:02) [GCC 4.2.1 Compatible Apple LLVM 7.3.0 (clang-703.0.31)]
Using /Users/mdelagrange/.ansible.cfg as config file
setting up inventory plugins
Parsed /Users/mdelagrange/src/ops/ansible/inventory/get-ec2-inv.sh inventory source with script plugin
Parsed /Users/mdelagrange/src/ops/ansible/inventory/riad3 inventory source with ini plugin
Parsed /Users/mdelagrange/src/ops/ansible/inventory/sch1 inventory source with ini plugin
Parsed /Users/mdelagrange/src/ops/ansible/inventory/sch3 inventory source with ini plugin
Parsed /Users/mdelagrange/src/ops/ansible/inventory/transit-vpc inventory source with ini plugin
Parsed /Users/mdelagrange/src/ops/ansible/inventory/windows inventory source with ini plugin
Loading callback plugin default of type stdout, v2.0 from /Users/mdelagrange/src/github/ansible_include_role_bug/env/lib/python2.7/site-packages/ansible/plugins/callback/__init__.pyc

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

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

TASK [Gathering Facts] *********************************************************
Using module file /Users/mdelagrange/src/github/ansible_include_role_bug/env/lib/python2.7/site-packages/ansible/modules/system/setup.py
&lt;127.0.0.1&gt; ESTABLISH LOCAL CONNECTION FOR USER: mdelagrange
&lt;127.0.0.1&gt; EXEC /bin/sh -c 'echo ~ &amp;&amp; sleep 0'
&lt;127.0.0.1&gt; EXEC /bin/sh -c '( umask 77 &amp;&amp; mkdir -p &quot;` echo /Users/mdelagrange/.ansible/tmp/ansible-tmp-1512514023.91-184937761254613 `&quot; &amp;&amp; echo ansible-tmp-1512514023.91-184937761254613=&quot;` echo /Users/mdelagrange/.ansible/tmp/ansible-tmp-1512514023.91-184937761254613 `&quot; ) &amp;&amp; sleep 0'
&lt;127.0.0.1&gt; PUT /var/folders/vn/kb09q_5s3s92r1gmv_5n1yfxfp9c16/T/tmpCFOhU4 TO /Users/mdelagrange/.ansible/tmp/ansible-tmp-1512514023.91-184937761254613/setup.py
&lt;127.0.0.1&gt; EXEC /bin/sh -c 'chmod u+x /Users/mdelagrange/.ansible/tmp/ansible-tmp-1512514023.91-184937761254613/ /Users/mdelagrange/.ansible/tmp/ansible-tmp-1512514023.91-184937761254613/setup.py &amp;&amp; sleep 0'
&lt;127.0.0.1&gt; EXEC /bin/sh -c '/Users/mdelagrange/src/github/ansible_include_role_bug/env/bin/python2.7 /Users/mdelagrange/.ansible/tmp/ansible-tmp-1512514023.91-184937761254613/setup.py; rm -rf &quot;/Users/mdelagrange/.ansible/tmp/ansible-tmp-1512514023.91-184937761254613/&quot; &gt; /dev/null 2&gt;&amp;1 &amp;&amp; sleep 0'
ok: [localhost]
META: ran handlers

TASK [test_role : debug] *******************************************************
task path: /Users/mdelagrange/src/github/ansible_include_role_bug/roles/test_role/tasks/main.yml:1
ok: [localhost] =&gt; {
    &quot;msg&quot;: &quot;foo&quot;
}
META: ran handlers

TASK [include_role] ************************************************************
task path: /Users/mdelagrange/src/github/ansible_include_role_bug/test-playbook.yml:5
the full traceback was:

Traceback (most recent call last):
  File &quot;./env/bin/ansible-playbook&quot;, line 106, in &lt;module&gt;
    exit_code = cli.run()
  File &quot;/Users/mdelagrange/src/github/ansible_include_role_bug/env/lib/python2.7/site-packages/ansible/cli/playbook.py&quot;, line 130, in run
    results = pbex.run()
  File &quot;/Users/mdelagrange/src/github/ansible_include_role_bug/env/lib/python2.7/site-packages/ansible/executor/playbook_executor.py&quot;, line 154, in run
    result = self._tqm.run(play=play)
  File &quot;/Users/mdelagrange/src/github/ansible_include_role_bug/env/lib/python2.7/site-packages/ansible/executor/task_queue_manager.py&quot;, line 290, in run
    play_return = strategy.run(iterator, play_context)
  File &quot;/Users/mdelagrange/src/github/ansible_include_role_bug/env/lib/python2.7/site-packages/ansible/plugins/strategy/linear.py&quot;, line 292, in run
    results += self._wait_on_pending_results(iterator)
  File &quot;/Users/mdelagrange/src/github/ansible_include_role_bug/env/lib/python2.7/site-packages/ansible/plugins/strategy/__init__.py&quot;, line 586, in _wait_on_pending_results
    results = self._process_pending_results(iterator)
  File &quot;/Users/mdelagrange/src/github/ansible_include_role_bug/env/lib/python2.7/site-packages/ansible/plugins/strategy/__init__.py&quot;, line 548, in _process_pending_results
    self._tqm.send_callback('v2_runner_on_ok', task_result)
  File &quot;/Users/mdelagrange/src/github/ansible_include_role_bug/env/lib/python2.7/site-packages/ansible/executor/task_queue_manager.py&quot;, line 367, in send_callback
    new_args.append(arg.clean_copy())
  File &quot;/Users/mdelagrange/src/github/ansible_include_role_bug/env/lib/python2.7/site-packages/ansible/executor/task_result.py&quot;, line 109, in clean_copy
    result._result = deepcopy(self._result)
  File &quot;/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py&quot;, line 163, in deepcopy
    y = copier(x, memo)
  File &quot;/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py&quot;, line 257, in _deepcopy_dict
    y[deepcopy(key, memo)] = deepcopy(value, memo)
  File &quot;/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py&quot;, line 190, in deepcopy
    y = _reconstruct(x, rv, 1, memo)
  File &quot;/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py&quot;, line 334, in _reconstruct
    state = deepcopy(state, memo)
  File &quot;/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py&quot;, line 163, in deepcopy
    y = copier(x, memo)
  File &quot;/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py&quot;, line 257, in _deepcopy_dict
    y[deepcopy(key, memo)] = deepcopy(value, memo)
  File &quot;/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py&quot;, line 190, in deepcopy
    y = _reconstruct(x, rv, 1, memo)
  File &quot;/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py&quot;, line 334, in _reconstruct
    state = deepcopy(state, memo)
  File &quot;/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py&quot;, line 163, in deepcopy
    y = copier(x, memo)
  File &quot;/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py&quot;, line 257, in _deepcopy_dict
    y[deepcopy(key, memo)] = deepcopy(value, memo)
  File &quot;/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py&quot;, line 190, in deepcopy
    y = _reconstruct(x, rv, 1, memo)
  File &quot;/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py&quot;, line 334, in _reconstruct
    state = deepcopy(state, memo)
  File &quot;/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py&quot;, line 163, in deepcopy
    y = copier(x, memo)
  File &quot;/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py&quot;, line 257, in _deepcopy_dict
    y[deepcopy(key, memo)] = deepcopy(value, memo)
  File &quot;/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py&quot;, line 190, in deepcopy
    y = _reconstruct(x, rv, 1, memo)
  File &quot;/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py&quot;, line 334, in _reconstruct
    state = deepcopy(state, memo)
  File &quot;/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py&quot;, line 163, in deepcopy
    y = copier(x, memo)
  File &quot;/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py&quot;, line 257, in _deepcopy_dict
    y[deepcopy(key, memo)] = deepcopy(value, memo)
  File &quot;/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py&quot;, line 163, in deepcopy
    y = copier(x, memo)
  File &quot;/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py&quot;, line 257, in _deepcopy_dict
    y[deepcopy(key, memo)] = deepcopy(value, memo)
  File &quot;/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py&quot;, line 163, in deepcopy
    y = copier(x, memo)
  File &quot;/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py&quot;, line 230, in _deepcopy_list
    y.append(deepcopy(a, memo))
  File &quot;/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py&quot;, line 190, in deepcopy
    y = _reconstruct(x, rv, 1, memo)
  File &quot;/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py&quot;, line 334, in _reconstruct
    state = deepcopy(state, memo)

  [~2000 lines omitted]

  File &quot;/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py&quot;, line 257, in _deepcopy_dict
    y[deepcopy(key, memo)] = deepcopy(value, memo)
  File &quot;/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py&quot;, line 163, in deepcopy
    y = copier(x, memo)
  File &quot;/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py&quot;, line 230, in _deepcopy_list
    y.append(deepcopy(a, memo))
  File &quot;/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py&quot;, line 163, in deepcopy
    y = copier(x, memo)
  File &quot;/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py&quot;, line 257, in _deepcopy_dict
    y[deepcopy(key, memo)] = deepcopy(value, memo)
  File &quot;/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py&quot;, line 163, in deepcopy
    y = copier(x, memo)
  File &quot;/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py&quot;, line 230, in _deepcopy_list
    y.append(deepcopy(a, memo))
  File &quot;/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py&quot;, line 190, in deepcopy
    y = _reconstruct(x, rv, 1, memo)
  File &quot;/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py&quot;, line 334, in _reconstruct
    state = deepcopy(state, memo)
  File &quot;/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py&quot;, line 163, in deepcopy
    y = copier(x, memo)
  File &quot;/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py&quot;, line 257, in _deepcopy_dict
    y[deepcopy(key, memo)] = deepcopy(value, memo)
  File &quot;/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py&quot;, line 163, in deepcopy
    y = copier(x, memo)
  File &quot;/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py&quot;, line 230, in _deepcopy_list
    y.append(deepcopy(a, memo))
  File &quot;/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py&quot;, line 163, in deepcopy
    y = copier(x, memo)
  File &quot;/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py&quot;, line 257, in _deepcopy_dict
    y[deepcopy(key, memo)] = deepcopy(value, memo)
  File &quot;/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py&quot;, line 163, in deepcopy
    y = copier(x, memo)
  File &quot;/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py&quot;, line 230, in _deepcopy_list
    y.append(deepcopy(a, memo))
  File &quot;/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py&quot;, line 182, in deepcopy
    rv = reductor(2)
  File &quot;/Users/mdelagrange/src/github/ansible_include_role_bug/env/lib/python2.7/site-packages/ansible/inventory/host.py&quot;, line 34, in __getstate__
    return self.serialize()
  File &quot;/Users/mdelagrange/src/github/ansible_include_role_bug/env/lib/python2.7/site-packages/ansible/inventory/host.py&quot;, line 59, in serialize
    groups.append(group.serialize())
  File &quot;/Users/mdelagrange/src/github/ansible_include_role_bug/env/lib/python2.7/site-packages/ansible/inventory/group.py&quot;, line 55, in serialize
    parent_groups.append(parent.serialize())
  File &quot;/Users/mdelagrange/src/github/ansible_include_role_bug/env/lib/python2.7/site-packages/ansible/inventory/group.py&quot;, line 55, in serialize
    parent_groups.append(parent.serialize())
RuntimeError: maximum recursion depth exceeded
"><pre class="notranslate"><code class="notranslate">ansible-playbook 2.4.2.0
  config file = /Users/mdelagrange/.ansible.cfg
  configured module search path = [u'/Users/mdelagrange/src/ops/ansible/library']
  ansible python module location = /Users/mdelagrange/src/github/ansible_include_role_bug/env/lib/python2.7/site-packages/ansible
  executable location = ./env/bin/ansible-playbook
  python version = 2.7.12 (default, Jun 29 2016, 14:05:02) [GCC 4.2.1 Compatible Apple LLVM 7.3.0 (clang-703.0.31)]
Using /Users/mdelagrange/.ansible.cfg as config file
setting up inventory plugins
Parsed /Users/mdelagrange/src/ops/ansible/inventory/get-ec2-inv.sh inventory source with script plugin
Parsed /Users/mdelagrange/src/ops/ansible/inventory/riad3 inventory source with ini plugin
Parsed /Users/mdelagrange/src/ops/ansible/inventory/sch1 inventory source with ini plugin
Parsed /Users/mdelagrange/src/ops/ansible/inventory/sch3 inventory source with ini plugin
Parsed /Users/mdelagrange/src/ops/ansible/inventory/transit-vpc inventory source with ini plugin
Parsed /Users/mdelagrange/src/ops/ansible/inventory/windows inventory source with ini plugin
Loading callback plugin default of type stdout, v2.0 from /Users/mdelagrange/src/github/ansible_include_role_bug/env/lib/python2.7/site-packages/ansible/plugins/callback/__init__.pyc

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

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

TASK [Gathering Facts] *********************************************************
Using module file /Users/mdelagrange/src/github/ansible_include_role_bug/env/lib/python2.7/site-packages/ansible/modules/system/setup.py
&lt;127.0.0.1&gt; ESTABLISH LOCAL CONNECTION FOR USER: mdelagrange
&lt;127.0.0.1&gt; EXEC /bin/sh -c 'echo ~ &amp;&amp; sleep 0'
&lt;127.0.0.1&gt; EXEC /bin/sh -c '( umask 77 &amp;&amp; mkdir -p "` echo /Users/mdelagrange/.ansible/tmp/ansible-tmp-1512514023.91-184937761254613 `" &amp;&amp; echo ansible-tmp-1512514023.91-184937761254613="` echo /Users/mdelagrange/.ansible/tmp/ansible-tmp-1512514023.91-184937761254613 `" ) &amp;&amp; sleep 0'
&lt;127.0.0.1&gt; PUT /var/folders/vn/kb09q_5s3s92r1gmv_5n1yfxfp9c16/T/tmpCFOhU4 TO /Users/mdelagrange/.ansible/tmp/ansible-tmp-1512514023.91-184937761254613/setup.py
&lt;127.0.0.1&gt; EXEC /bin/sh -c 'chmod u+x /Users/mdelagrange/.ansible/tmp/ansible-tmp-1512514023.91-184937761254613/ /Users/mdelagrange/.ansible/tmp/ansible-tmp-1512514023.91-184937761254613/setup.py &amp;&amp; sleep 0'
&lt;127.0.0.1&gt; EXEC /bin/sh -c '/Users/mdelagrange/src/github/ansible_include_role_bug/env/bin/python2.7 /Users/mdelagrange/.ansible/tmp/ansible-tmp-1512514023.91-184937761254613/setup.py; rm -rf "/Users/mdelagrange/.ansible/tmp/ansible-tmp-1512514023.91-184937761254613/" &gt; /dev/null 2&gt;&amp;1 &amp;&amp; sleep 0'
ok: [localhost]
META: ran handlers

TASK [test_role : debug] *******************************************************
task path: /Users/mdelagrange/src/github/ansible_include_role_bug/roles/test_role/tasks/main.yml:1
ok: [localhost] =&gt; {
    "msg": "foo"
}
META: ran handlers

TASK [include_role] ************************************************************
task path: /Users/mdelagrange/src/github/ansible_include_role_bug/test-playbook.yml:5
the full traceback was:

Traceback (most recent call last):
  File "./env/bin/ansible-playbook", line 106, in &lt;module&gt;
    exit_code = cli.run()
  File "/Users/mdelagrange/src/github/ansible_include_role_bug/env/lib/python2.7/site-packages/ansible/cli/playbook.py", line 130, in run
    results = pbex.run()
  File "/Users/mdelagrange/src/github/ansible_include_role_bug/env/lib/python2.7/site-packages/ansible/executor/playbook_executor.py", line 154, in run
    result = self._tqm.run(play=play)
  File "/Users/mdelagrange/src/github/ansible_include_role_bug/env/lib/python2.7/site-packages/ansible/executor/task_queue_manager.py", line 290, in run
    play_return = strategy.run(iterator, play_context)
  File "/Users/mdelagrange/src/github/ansible_include_role_bug/env/lib/python2.7/site-packages/ansible/plugins/strategy/linear.py", line 292, in run
    results += self._wait_on_pending_results(iterator)
  File "/Users/mdelagrange/src/github/ansible_include_role_bug/env/lib/python2.7/site-packages/ansible/plugins/strategy/__init__.py", line 586, in _wait_on_pending_results
    results = self._process_pending_results(iterator)
  File "/Users/mdelagrange/src/github/ansible_include_role_bug/env/lib/python2.7/site-packages/ansible/plugins/strategy/__init__.py", line 548, in _process_pending_results
    self._tqm.send_callback('v2_runner_on_ok', task_result)
  File "/Users/mdelagrange/src/github/ansible_include_role_bug/env/lib/python2.7/site-packages/ansible/executor/task_queue_manager.py", line 367, in send_callback
    new_args.append(arg.clean_copy())
  File "/Users/mdelagrange/src/github/ansible_include_role_bug/env/lib/python2.7/site-packages/ansible/executor/task_result.py", line 109, in clean_copy
    result._result = deepcopy(self._result)
  File "/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py", line 163, in deepcopy
    y = copier(x, memo)
  File "/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py", line 257, in _deepcopy_dict
    y[deepcopy(key, memo)] = deepcopy(value, memo)
  File "/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py", line 190, in deepcopy
    y = _reconstruct(x, rv, 1, memo)
  File "/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py", line 334, in _reconstruct
    state = deepcopy(state, memo)
  File "/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py", line 163, in deepcopy
    y = copier(x, memo)
  File "/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py", line 257, in _deepcopy_dict
    y[deepcopy(key, memo)] = deepcopy(value, memo)
  File "/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py", line 190, in deepcopy
    y = _reconstruct(x, rv, 1, memo)
  File "/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py", line 334, in _reconstruct
    state = deepcopy(state, memo)
  File "/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py", line 163, in deepcopy
    y = copier(x, memo)
  File "/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py", line 257, in _deepcopy_dict
    y[deepcopy(key, memo)] = deepcopy(value, memo)
  File "/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py", line 190, in deepcopy
    y = _reconstruct(x, rv, 1, memo)
  File "/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py", line 334, in _reconstruct
    state = deepcopy(state, memo)
  File "/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py", line 163, in deepcopy
    y = copier(x, memo)
  File "/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py", line 257, in _deepcopy_dict
    y[deepcopy(key, memo)] = deepcopy(value, memo)
  File "/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py", line 190, in deepcopy
    y = _reconstruct(x, rv, 1, memo)
  File "/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py", line 334, in _reconstruct
    state = deepcopy(state, memo)
  File "/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py", line 163, in deepcopy
    y = copier(x, memo)
  File "/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py", line 257, in _deepcopy_dict
    y[deepcopy(key, memo)] = deepcopy(value, memo)
  File "/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py", line 163, in deepcopy
    y = copier(x, memo)
  File "/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py", line 257, in _deepcopy_dict
    y[deepcopy(key, memo)] = deepcopy(value, memo)
  File "/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py", line 163, in deepcopy
    y = copier(x, memo)
  File "/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py", line 230, in _deepcopy_list
    y.append(deepcopy(a, memo))
  File "/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py", line 190, in deepcopy
    y = _reconstruct(x, rv, 1, memo)
  File "/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py", line 334, in _reconstruct
    state = deepcopy(state, memo)

  [~2000 lines omitted]

  File "/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py", line 257, in _deepcopy_dict
    y[deepcopy(key, memo)] = deepcopy(value, memo)
  File "/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py", line 163, in deepcopy
    y = copier(x, memo)
  File "/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py", line 230, in _deepcopy_list
    y.append(deepcopy(a, memo))
  File "/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py", line 163, in deepcopy
    y = copier(x, memo)
  File "/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py", line 257, in _deepcopy_dict
    y[deepcopy(key, memo)] = deepcopy(value, memo)
  File "/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py", line 163, in deepcopy
    y = copier(x, memo)
  File "/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py", line 230, in _deepcopy_list
    y.append(deepcopy(a, memo))
  File "/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py", line 190, in deepcopy
    y = _reconstruct(x, rv, 1, memo)
  File "/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py", line 334, in _reconstruct
    state = deepcopy(state, memo)
  File "/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py", line 163, in deepcopy
    y = copier(x, memo)
  File "/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py", line 257, in _deepcopy_dict
    y[deepcopy(key, memo)] = deepcopy(value, memo)
  File "/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py", line 163, in deepcopy
    y = copier(x, memo)
  File "/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py", line 230, in _deepcopy_list
    y.append(deepcopy(a, memo))
  File "/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py", line 163, in deepcopy
    y = copier(x, memo)
  File "/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py", line 257, in _deepcopy_dict
    y[deepcopy(key, memo)] = deepcopy(value, memo)
  File "/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py", line 163, in deepcopy
    y = copier(x, memo)
  File "/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py", line 230, in _deepcopy_list
    y.append(deepcopy(a, memo))
  File "/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py", line 182, in deepcopy
    rv = reductor(2)
  File "/Users/mdelagrange/src/github/ansible_include_role_bug/env/lib/python2.7/site-packages/ansible/inventory/host.py", line 34, in __getstate__
    return self.serialize()
  File "/Users/mdelagrange/src/github/ansible_include_role_bug/env/lib/python2.7/site-packages/ansible/inventory/host.py", line 59, in serialize
    groups.append(group.serialize())
  File "/Users/mdelagrange/src/github/ansible_include_role_bug/env/lib/python2.7/site-packages/ansible/inventory/group.py", line 55, in serialize
    parent_groups.append(parent.serialize())
  File "/Users/mdelagrange/src/github/ansible_include_role_bug/env/lib/python2.7/site-packages/ansible/inventory/group.py", line 55, in serialize
    parent_groups.append(parent.serialize())
RuntimeError: maximum recursion depth exceeded

</code></pre></div>
<h5 dir="auto">ISSUE TYPE</h5>
<ul dir="auto">
<li>Bug Report</li>
</ul>
<h5 dir="auto">COMPONENT NAME</h5>
<p dir="auto">include and include_role</p>
<h5 dir="auto">ANSIBLE VERSION</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="ansible 2.2.1.0
  config file =
  configured module search path = Default w/o overrides"><pre class="notranslate"><code class="notranslate">ansible 2.2.1.0
  config file =
  configured module search path = Default w/o overrides
</code></pre></div>
<h5 dir="auto">CONFIGURATION</h5>
<p dir="auto">No change</p>
<h5 dir="auto">OS / ENVIRONMENT</h5>
<p dir="auto">Red Hat Enterprise Linux Server release 6.6</p>
<h5 dir="auto">SUMMARY</h5>
<p dir="auto">Nested include leads to the following error:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Exception RuntimeError: 'maximum recursion depth exceeded while calling a Python object' in &lt;type 'exceptions.RuntimeError'&gt; ignored
ERROR! Unexpected Exception: maximum recursion depth exceeded"><pre class="notranslate"><code class="notranslate">Exception RuntimeError: 'maximum recursion depth exceeded while calling a Python object' in &lt;type 'exceptions.RuntimeError'&gt; ignored
ERROR! Unexpected Exception: maximum recursion depth exceeded
</code></pre></div>
<p dir="auto">The error occurs with real playbooks with a mix of 5 nested include_role and include<br>
playbook:<br>
role<br>
include_role<br>
include_role<br>
include_role<br>
include<br>
include</p>
<p dir="auto">It's reproducible with a playbook with 12 nested include.</p>
<h5 dir="auto">STEPS TO REPRODUCE</h5>


<div class="highlight highlight-source-yaml notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="Playbook:
- hosts: localhost
  roles:
    - role1

role1/tasks/main.yml:
---
- name: &quot;include: r1t1.yml&quot;
  include: r1t1.yml

role1/tasks/r1t1.yml:
- name: &quot;include r1t2&quot;
  include: r1t2.yml

and so on up to role1/tasks/r1t12.yml:
---
- debug: msg=&quot;r1t12&quot;"><pre class="notranslate"><span class="pl-ent">Playbook</span>:
- <span class="pl-ent">hosts</span>: <span class="pl-s">localhost</span>
  <span class="pl-ent">roles</span>:
    - <span class="pl-s">role1</span>

<span class="pl-ent">role1/tasks/main.yml</span>:
---
- <span class="pl-ent">name</span>: <span class="pl-s"><span class="pl-pds">"</span>include: r1t1.yml<span class="pl-pds">"</span></span>
  <span class="pl-ent">include</span>: <span class="pl-s">r1t1.yml</span>

<span class="pl-ent">role1/tasks/r1t1.yml</span>:
- <span class="pl-ent">name</span>: <span class="pl-s"><span class="pl-pds">"</span>include r1t2<span class="pl-pds">"</span></span>
  <span class="pl-ent">include</span>: <span class="pl-s">r1t2.yml</span>

<span class="pl-ent">and so on up to role1/tasks/r1t12.yml</span>:
---
- <span class="pl-ent">debug</span>: <span class="pl-s">msg="r1t12"</span></pre></div>

<h5 dir="auto">EXPECTED RESULTS</h5>
<p dir="auto">Playbook runs successfully.</p>
<h5 dir="auto">ACTUAL RESULTS</h5>


<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="ansible-playbook -vv test.yml
No config file found; using defaults
 [WARNING]: Host file not found: /etc/ansible/hosts

 [WARNING]: provided hosts list is empty, only localhost is available

statically included: /home/user/test/role1/tasks/r1t1.yml
statically included: /home/user/test/role1/tasks/r1t2.yml
statically included: /home/user/test/role1/tasks/r1t3.yml
statically included: /home/user/test/role1/tasks/r1t4.yml
statically included: /home/user/test/role1/tasks/r1t5.yml
statically included: /home/user/test/role1/tasks/r1t6.yml
statically included: /home/user/test/role1/tasks/r1t7.yml
statically included: /home/user/test/role1/tasks/r1t8.yml
statically included: /home/user/test/role1/tasks/r1t9.yml
statically included: /home/user/test/role1/tasks/r1t10.yml
statically included: /home/user/test/role1/tasks/r1t11.yml
statically included: /home/user/test/role1/tasks/r1t12.yml

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

PLAY [localhost] ***************************************************************
Exception RuntimeError: 'maximum recursion depth exceeded while calling a Python object' in &lt;type 'exceptions.RuntimeError'&gt; ignored
ERROR! Unexpected Exception: maximum recursion depth exceeded
"><pre class="notranslate"><code class="notranslate">ansible-playbook -vv test.yml
No config file found; using defaults
 [WARNING]: Host file not found: /etc/ansible/hosts

 [WARNING]: provided hosts list is empty, only localhost is available

statically included: /home/user/test/role1/tasks/r1t1.yml
statically included: /home/user/test/role1/tasks/r1t2.yml
statically included: /home/user/test/role1/tasks/r1t3.yml
statically included: /home/user/test/role1/tasks/r1t4.yml
statically included: /home/user/test/role1/tasks/r1t5.yml
statically included: /home/user/test/role1/tasks/r1t6.yml
statically included: /home/user/test/role1/tasks/r1t7.yml
statically included: /home/user/test/role1/tasks/r1t8.yml
statically included: /home/user/test/role1/tasks/r1t9.yml
statically included: /home/user/test/role1/tasks/r1t10.yml
statically included: /home/user/test/role1/tasks/r1t11.yml
statically included: /home/user/test/role1/tasks/r1t12.yml

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

PLAY [localhost] ***************************************************************
Exception RuntimeError: 'maximum recursion depth exceeded while calling a Python object' in &lt;type 'exceptions.RuntimeError'&gt; ignored
ERROR! Unexpected Exception: maximum recursion depth exceeded

</code></pre></div>
<p dir="auto"><a href="https://github.com/ansible/ansible/files/922089/ansible-include-issue.zip">ansible-include-issue.zip</a></p>