Issue 1:
ISSUE TYPE

Bug Report

COMPONENT NAME

include module

ANSIBLE VERSION

v2.3.0.0-0.3.rc3:

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)]```

CONFIGURATION

default

OS / ENVIRONMENT

Fedora release 25 (Twenty Five)

SUMMARY

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.

STEPS TO REPRODUCE

test.yml:

---
- hosts: localhost

roles:
- role: a
a:
name: a1
- role: a
a:
name: a2

roles/a/meta/main.yml:

---
dependencies:
- role: b
b:
name: "{{ a.name }}"

roles/a/tasks/main.yml

---
- name: output name
debug:
msg: "{{ a.name }}"

- include: include.yml
static: no

roles/a/tasks/include.yml:

---
- name: output name in include
debug:
msg: "{{ a.name }}"

roles/b/meta/main.yml:

---
allow_duplicates: yes

roles/b/tasks/main.yml:

---
- name: output name
debug:
msg: "{{ b.name }}"

- include: include.yml
static: no

roles/b/tasks/include.yml:

---
- name: output name in include
debug:
msg: "{{ b.name }}"

I have made test repo: https://github.com/mesk41in/ansible-include-test.

EXPECTED RESULTS

In second task "b : output name in include" value of "msg" must be "a2".

ACTUAL RESULTS

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

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

TASK [b : output name] ***********************************************************************************************************************************************************************************************************************
ok: [localhost] => {
"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] => {
"changed": false,
"msg": "a1"
}

TASK [a : output name] ***********************************************************************************************************************************************************************************************************************
ok: [localhost] => {
"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] => {
"changed": false,
"msg": "a1"
}

TASK [b : output name] ***********************************************************************************************************************************************************************************************************************
ok: [localhost] => {
"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] => {
"changed": false,
"msg": "a1"
}

TASK [a : output name] ***********************************************************************************************************************************************************************************************************************
ok: [localhost] => {
"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] => {
"changed": false,
"msg": "a2"
}

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

Issue 2:
ISSUE TYPE

Bug Report

COMPONENT NAME

ansible core

ANSIBLE VERSION

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

CONFIGURATION

None

OS / ENVIRONMENT

macOS Sierra 10.11.6

Python 2.7.13

SUMMARY

Lists containing integers are casted to strings when using set_fact

STEPS TO REPRODUCE

- hosts: localhost
vars:
numbers:
- 123
- 234

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

- name: set fact_number = numbers[0]
set_fact: fact_number="{{ numbers[0] }}"

- name: show fact_number
debug: msg="{{ fact_number | to_json }}"

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

- name: show fact_number
debug: msg="{{ fact_number | to_json }}"

EXPECTED RESULTS

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

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

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

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

TASK [show fact_number] ********************************************************
ok: [localhost] => {
"msg": "123"
}

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

TASK [show fact_number] ********************************************************
ok: [localhost] => {
"msg": "123"
}

ACTUAL RESULTS

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

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

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

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

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

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

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