<h5 dir="auto">ISSUE TYPE</h5>
<ul dir="auto">
<li>Bug Report</li>
</ul>
<h5 dir="auto">COMPONENT NAME</h5>
<p dir="auto">include module</p>
<h5 dir="auto">ANSIBLE VERSION</h5>
<ul dir="auto">
<li>v2.3.0.0-0.3.rc3:</li>
</ul>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="ansible 2.3.0.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = Default w/o overrides
  python version = 2.7.13 (default, Jan 12 2017, 17:59:37) [GCC 6.3.1 20161221 (Red Hat 6.3.1-1)]```"><pre class="notranslate"><code class="notranslate">ansible 2.3.0.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = Default w/o overrides
  python version = 2.7.13 (default, Jan 12 2017, 17:59:37) [GCC 6.3.1 20161221 (Red Hat 6.3.1-1)]```
</code></pre></div>
<h5 dir="auto">CONFIGURATION</h5>
<p dir="auto">default</p>
<h5 dir="auto">OS / ENVIRONMENT</h5>
<p dir="auto">Fedora release 25 (Twenty Five)</p>
<h5 dir="auto">SUMMARY</h5>
<p dir="auto">Dynamic include breaks variables in dependent role. I think it is related with "allow_duplicates: yes" in dependent role. It looks like dynamic include uses the first "scope" of variables.</p>
<h5 dir="auto">STEPS TO REPRODUCE</h5>
<ul dir="auto">
<li>test.yml:</li>
</ul>
<div class="highlight highlight-source-yaml notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="---
- hosts: localhost

  roles:
    - role: a
      a:
        name: a1
    - role: a
      a:
        name: a2"><pre class="notranslate">---
- <span class="pl-ent">hosts</span>: <span class="pl-s">localhost</span>

  <span class="pl-ent">roles</span>:
    - <span class="pl-ent">role</span>: <span class="pl-s">a</span>
      <span class="pl-ent">a</span>:
        <span class="pl-ent">name</span>: <span class="pl-c1">a1</span>
    - <span class="pl-ent">role</span>: <span class="pl-s">a</span>
      <span class="pl-ent">a</span>:
        <span class="pl-ent">name</span>: <span class="pl-c1">a2</span></pre></div>
<ul dir="auto">
<li>roles/a/meta/main.yml:</li>
</ul>
<div class="highlight highlight-source-yaml notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="---
dependencies:
  - role: b
    b:
      name: &quot;{{ a.name }}&quot;"><pre class="notranslate">---
<span class="pl-ent">dependencies</span>:
  - <span class="pl-ent">role</span>: <span class="pl-s">b</span>
    <span class="pl-ent">b</span>:
      <span class="pl-ent">name</span>: <span class="pl-s"><span class="pl-pds">"</span>{{ a.name }}<span class="pl-pds">"</span></span></pre></div>
<ul dir="auto">
<li>roles/a/tasks/main.yml</li>
</ul>
<div class="highlight highlight-source-yaml notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="---
- name: output name
  debug:
    msg: &quot;{{ a.name }}&quot;

- include: include.yml
  static: no"><pre class="notranslate">---
- <span class="pl-ent">name</span>: <span class="pl-s">output name</span>
  <span class="pl-ent">debug</span>:
    <span class="pl-ent">msg</span>: <span class="pl-s"><span class="pl-pds">"</span>{{ a.name }}<span class="pl-pds">"</span></span>

- <span class="pl-ent">include</span>: <span class="pl-s">include.yml</span>
  <span class="pl-ent">static</span>: <span class="pl-s">no</span></pre></div>
<ul dir="auto">
<li>roles/a/tasks/include.yml:</li>
</ul>
<div class="highlight highlight-source-yaml notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="---
- name: output name in include
  debug:
    msg: &quot;{{ a.name }}&quot;"><pre class="notranslate">---
- <span class="pl-ent">name</span>: <span class="pl-s">output name in include</span>
  <span class="pl-ent">debug</span>:
    <span class="pl-ent">msg</span>: <span class="pl-s"><span class="pl-pds">"</span>{{ a.name }}<span class="pl-pds">"</span></span></pre></div>
<ul dir="auto">
<li>roles/b/meta/main.yml:</li>
</ul>
<div class="highlight highlight-source-yaml notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="---
allow_duplicates: yes"><pre class="notranslate">---
<span class="pl-ent">allow_duplicates</span>: <span class="pl-s">yes</span></pre></div>
<ul dir="auto">
<li>roles/b/tasks/main.yml:</li>
</ul>
<div class="highlight highlight-source-yaml notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="---
- name: output name
  debug:
    msg: &quot;{{ b.name }}&quot;

- include: include.yml
  static: no"><pre class="notranslate">---
- <span class="pl-ent">name</span>: <span class="pl-s">output name</span>
  <span class="pl-ent">debug</span>:
    <span class="pl-ent">msg</span>: <span class="pl-s"><span class="pl-pds">"</span>{{ b.name }}<span class="pl-pds">"</span></span>

- <span class="pl-ent">include</span>: <span class="pl-s">include.yml</span>
  <span class="pl-ent">static</span>: <span class="pl-s">no</span></pre></div>
<ul dir="auto">
<li>roles/b/tasks/include.yml:</li>
</ul>
<div class="highlight highlight-source-yaml notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="---
- name: output name in include
  debug:
    msg: &quot;{{ b.name }}&quot;"><pre class="notranslate">---
- <span class="pl-ent">name</span>: <span class="pl-s">output name in include</span>
  <span class="pl-ent">debug</span>:
    <span class="pl-ent">msg</span>: <span class="pl-s"><span class="pl-pds">"</span>{{ b.name }}<span class="pl-pds">"</span></span></pre></div>
<p dir="auto">I have made test repo: <a href="https://github.com/mesk41in/ansible-include-test">https://github.com/mesk41in/ansible-include-test</a>.</p>
<h5 dir="auto">EXPECTED RESULTS</h5>
<p dir="auto">In second task "b : output name in include" value of "msg" must be "a2".</p>
<h5 dir="auto">ACTUAL RESULTS</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="PLAY [localhost] *****************************************************************************************************************************************************************************************************************************

TASK [Gathering Facts] ***********************************************************************************************************************************************************************************************************************
ok: [localhost]

TASK [b : output name] ***********************************************************************************************************************************************************************************************************************
ok: [localhost] =&gt; {
    &quot;changed&quot;: false, 
    &quot;msg&quot;: &quot;a1&quot;
}

TASK [b : include] ***************************************************************************************************************************************************************************************************************************
included: /root/Documents/ansible_include_test/roles/b/tasks/include.yml for localhost

TASK [b : output name in include] ************************************************************************************************************************************************************************************************************
ok: [localhost] =&gt; {
    &quot;changed&quot;: false, 
    &quot;msg&quot;: &quot;a1&quot;
}

TASK [a : output name] ***********************************************************************************************************************************************************************************************************************
ok: [localhost] =&gt; {
    &quot;changed&quot;: false, 
    &quot;msg&quot;: &quot;a1&quot;
}

TASK [a : include] ***************************************************************************************************************************************************************************************************************************
included: /root/Documents/ansible_include_test/roles/a/tasks/include.yml for localhost

TASK [a : output name in include] ************************************************************************************************************************************************************************************************************
ok: [localhost] =&gt; {
    &quot;changed&quot;: false, 
    &quot;msg&quot;: &quot;a1&quot;
}

TASK [b : output name] ***********************************************************************************************************************************************************************************************************************
ok: [localhost] =&gt; {
    &quot;changed&quot;: false, 
    &quot;msg&quot;: &quot;a2&quot;
}

TASK [b : include] ***************************************************************************************************************************************************************************************************************************
included: /root/Documents/ansible_include_test/roles/b/tasks/include.yml for localhost

TASK [b : output name in include] ************************************************************************************************************************************************************************************************************
ok: [localhost] =&gt; {
    &quot;changed&quot;: false, 
    &quot;msg&quot;: &quot;a1&quot;
}

TASK [a : output name] ***********************************************************************************************************************************************************************************************************************
ok: [localhost] =&gt; {
    &quot;changed&quot;: false, 
    &quot;msg&quot;: &quot;a2&quot;
}

TASK [a : include] ***************************************************************************************************************************************************************************************************************************
included: /root/Documents/ansible_include_test/roles/a/tasks/include.yml for localhost

TASK [a : output name in include] ************************************************************************************************************************************************************************************************************
ok: [localhost] =&gt; {
    &quot;changed&quot;: false, 
    &quot;msg&quot;: &quot;a2&quot;
}

PLAY RECAP ***********************************************************************************************************************************************************************************************************************************
localhost                  : ok=13   changed=0    unreachable=0    failed=0"><pre class="notranslate"><code class="notranslate">PLAY [localhost] *****************************************************************************************************************************************************************************************************************************

TASK [Gathering Facts] ***********************************************************************************************************************************************************************************************************************
ok: [localhost]

TASK [b : output name] ***********************************************************************************************************************************************************************************************************************
ok: [localhost] =&gt; {
    "changed": false, 
    "msg": "a1"
}

TASK [b : include] ***************************************************************************************************************************************************************************************************************************
included: /root/Documents/ansible_include_test/roles/b/tasks/include.yml for localhost

TASK [b : output name in include] ************************************************************************************************************************************************************************************************************
ok: [localhost] =&gt; {
    "changed": false, 
    "msg": "a1"
}

TASK [a : output name] ***********************************************************************************************************************************************************************************************************************
ok: [localhost] =&gt; {
    "changed": false, 
    "msg": "a1"
}

TASK [a : include] ***************************************************************************************************************************************************************************************************************************
included: /root/Documents/ansible_include_test/roles/a/tasks/include.yml for localhost

TASK [a : output name in include] ************************************************************************************************************************************************************************************************************
ok: [localhost] =&gt; {
    "changed": false, 
    "msg": "a1"
}

TASK [b : output name] ***********************************************************************************************************************************************************************************************************************
ok: [localhost] =&gt; {
    "changed": false, 
    "msg": "a2"
}

TASK [b : include] ***************************************************************************************************************************************************************************************************************************
included: /root/Documents/ansible_include_test/roles/b/tasks/include.yml for localhost

TASK [b : output name in include] ************************************************************************************************************************************************************************************************************
ok: [localhost] =&gt; {
    "changed": false, 
    "msg": "a1"
}

TASK [a : output name] ***********************************************************************************************************************************************************************************************************************
ok: [localhost] =&gt; {
    "changed": false, 
    "msg": "a2"
}

TASK [a : include] ***************************************************************************************************************************************************************************************************************************
included: /root/Documents/ansible_include_test/roles/a/tasks/include.yml for localhost

TASK [a : output name in include] ************************************************************************************************************************************************************************************************************
ok: [localhost] =&gt; {
    "changed": false, 
    "msg": "a2"
}

PLAY RECAP ***********************************************************************************************************************************************************************************************************************************
localhost                  : ok=13   changed=0    unreachable=0    failed=0
</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">ansible core</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.0.0
  config file = 
  configured module search path = Default w/o overrides"><pre class="notranslate"><code class="notranslate">ansible 2.2.0.0
  config file = 
  configured module search path = Default w/o overrides
</code></pre></div>
<h5 dir="auto">CONFIGURATION</h5>
<p dir="auto">None</p>
<h5 dir="auto">OS / ENVIRONMENT</h5>
<p dir="auto">macOS Sierra 10.11.6<br>
Python 2.7.13</p>
<h5 dir="auto">SUMMARY</h5>
<p dir="auto">Lists containing integers are casted to strings when using <code class="notranslate">set_fact</code></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="- hosts: localhost
  vars:
    numbers:
      - 123
      - 234

  tasks:
    - name: show numbers[0]
      debug: msg=&quot;{{ numbers[0] | to_json }}&quot;

    - name: set fact_number = numbers[0]
      set_fact: fact_number=&quot;{{ numbers[0] }}&quot;

    - name: show fact_number
      debug: msg=&quot;{{ fact_number | to_json }}&quot;

    - name: set fact_number = numbers[0] and expilicitly cast to int
      set_fact: fact_number=&quot;{{ numbers[0] | int }}&quot;

    - name: show fact_number
      debug: msg=&quot;{{ fact_number | to_json }}&quot;"><pre class="notranslate">- <span class="pl-ent">hosts</span>: <span class="pl-s">localhost</span>
  <span class="pl-ent">vars</span>:
    <span class="pl-ent">numbers</span>:
      - <span class="pl-c1">123</span>
      - <span class="pl-c1">234</span>

  <span class="pl-ent">tasks</span>:
    - <span class="pl-ent">name</span>: <span class="pl-s">show numbers[0]</span>
      <span class="pl-ent">debug</span>: <span class="pl-s">msg="{{ numbers[0] | to_json }}"</span>

    - <span class="pl-ent">name</span>: <span class="pl-s">set fact_number = numbers[0]</span>
      <span class="pl-ent">set_fact</span>: <span class="pl-s">fact_number="{{ numbers[0] }}"</span>

    - <span class="pl-ent">name</span>: <span class="pl-s">show fact_number</span>
      <span class="pl-ent">debug</span>: <span class="pl-s">msg="{{ fact_number | to_json }}"</span>

    - <span class="pl-ent">name</span>: <span class="pl-s">set fact_number = numbers[0] and expilicitly cast to int</span>
      <span class="pl-ent">set_fact</span>: <span class="pl-s">fact_number="{{ numbers[0] | int }}"</span>

    - <span class="pl-ent">name</span>: <span class="pl-s">show fact_number</span>
      <span class="pl-ent">debug</span>: <span class="pl-s">msg="{{ fact_number | to_json }}"</span></pre></div>
<h5 dir="auto">EXPECTED RESULTS</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="PLAY [localhost] ***************************************************************

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

TASK [show numbers[0]] *********************************************************
ok: [localhost] =&gt; {
    &quot;msg&quot;: &quot;123&quot;
}

TASK [set fact_number = numbers[0]] ********************************************
ok: [localhost]

TASK [show fact_number] ********************************************************
ok: [localhost] =&gt; {
    &quot;msg&quot;: &quot;123&quot;
}

TASK [set fact_number = numbers[0] and expilicitly cast to int] ****************
ok: [localhost]

TASK [show fact_number] ********************************************************
ok: [localhost] =&gt; {
    &quot;msg&quot;: &quot;123&quot;
}"><pre class="notranslate"><code class="notranslate">PLAY [localhost] ***************************************************************

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

TASK [show numbers[0]] *********************************************************
ok: [localhost] =&gt; {
    "msg": "123"
}

TASK [set fact_number = numbers[0]] ********************************************
ok: [localhost]

TASK [show fact_number] ********************************************************
ok: [localhost] =&gt; {
    "msg": "123"
}

TASK [set fact_number = numbers[0] and expilicitly cast to int] ****************
ok: [localhost]

TASK [show fact_number] ********************************************************
ok: [localhost] =&gt; {
    "msg": "123"
}
</code></pre></div>
<h5 dir="auto">ACTUAL RESULTS</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="PLAY [localhost] ***************************************************************

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

TASK [show numbers[0]] *********************************************************
ok: [localhost] =&gt; {
    &quot;msg&quot;: &quot;123&quot;
}

TASK [set fact_number = numbers[0]] ********************************************
ok: [localhost]

TASK [show fact_number] ********************************************************
ok: [localhost] =&gt; {
    &quot;msg&quot;: &quot;\&quot;123\&quot;&quot;
}

TASK [set fact_number = numbers[0] and expilicitly cast to int] ****************
ok: [localhost]

TASK [show fact_number] ********************************************************
ok: [localhost] =&gt; {
    &quot;msg&quot;: &quot;\&quot;123\&quot;&quot;
}"><pre class="notranslate"><code class="notranslate">PLAY [localhost] ***************************************************************

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

TASK [show numbers[0]] *********************************************************
ok: [localhost] =&gt; {
    "msg": "123"
}

TASK [set fact_number = numbers[0]] ********************************************
ok: [localhost]

TASK [show fact_number] ********************************************************
ok: [localhost] =&gt; {
    "msg": "\"123\""
}

TASK [set fact_number = numbers[0] and expilicitly cast to int] ****************
ok: [localhost]

TASK [show fact_number] ********************************************************
ok: [localhost] =&gt; {
    "msg": "\"123\""
}
</code></pre></div>