Issue 1:
Create two roles, for instance "nginx" and "tomcat"; define variable files in each role with a 'version' variable, set to match expected versions of nginx and tomcat; create a playbook which associates both 'nginx' and 'tomcat' roles to a set of hosts.

Depending on order of execution, it appears that ansible overwrites the tomcat:version property with the nginx:version property, and then attempts to install tomcat-{{nginx:version}} which fails.

Either documentation should be updated to reflect the idea that roles maintain variables in a global namespace, or roles should be updated to auto-namespace vars files inside them, such that similarly named vars can co-exist between roles.

Issue 2:
ISSUE TYPE

Bug Report

COMPONENT NAME

Playbooks/Roles

ANSIBLE VERSION

ansible 2.2.1.0
config file = /etc/ansible/ansible.cfg
configured module search path = Default w/o overrides

CONFIGURATION

nowcows=1

OS / ENVIRONMENT

N/A (Ubuntu)

SUMMARY

When a role is invoked through a playbook and also referenced as a dependency it is executed twice.

STEPS TO REPRODUCE

==> playbook.yml <==
---
- hosts: localhost

roles:
- role: A
- role: B
- role: C

==> roles/A/tasks/main.yml <==
---
- debug: msg=A

==> roles/B/meta/main.yml <==
dependencies:
- name: A

==> roles/B/tasks/main.yml <==
---
- debug: msg=B

==> roles/C/meta/main.yml <==
dependencies:
- name: A

==> roles/C/tasks/main.yml <==
---
- debug: msg=C

EXPECTED RESULTS

Have roles A, B, C each execute once.

ACTUAL RESULTS

Role A runs twice, then role B and C run.

Using /etc/ansible/ansible.cfg as config file
[WARNING]: provided hosts list is empty, only localhost is available

Loading callback plugin default of type stdout, v2.0 from /usr/lib/python2.7/dist-packages/ansible/plugins/callback/__init__.pyc

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

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

TASK [setup] *******************************************************************
Using module file /usr/lib/python2.7/dist-packages/ansible/modules/core/system/setup.py
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: ubuntu
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo ~/.ansible/tmp/ansible-tmp-1488405550.52-260200123218035 `" && echo ansible-tmp-1488405550.52-260200123218035="` echo ~/.ansible/tmp/ansible-tmp-1488405550.52-260200123218035 `" ) && sleep 0'
<127.0.0.1> PUT /tmp/tmpF6ZqnV TO /home/ubuntu/.ansible/tmp/ansible-tmp-1488405550.52-260200123218035/setup.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /home/ubuntu/.ansible/tmp/ansible-tmp-1488405550.52-260200123218035/ /home/ubuntu/.ansible/tmp/ansible-tmp-1488405550.52-260200123218035/setup.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '/usr/bin/python /home/ubuntu/.ansible/tmp/ansible-tmp-1488405550.52-260200123218035/setup.py; rm -rf "/home/ubuntu/.ansible/tmp/ansible-tmp-1488405550.52-260200123218035/" > /dev/null 2>&1 && sleep 0'
ok: [localhost]

TASK [A : debug] ***************************************************************
task path: /home/ubuntu/demo-ansible-multiple_role-bug/roles/A/tasks/main.yml:2
ok: [localhost] => {
"msg": "A"
}

TASK [A : debug] ***************************************************************
task path: /home/ubuntu/demo-ansible-multiple_role-bug/roles/A/tasks/main.yml:2
ok: [localhost] => {
"msg": "A"
}

TASK [B : debug] ***************************************************************
task path: /home/ubuntu/demo-ansible-multiple_role-bug/roles/B/tasks/main.yml:2
ok: [localhost] => {
"msg": "B"
}

TASK [C : debug] ***************************************************************
task path: /home/ubuntu/demo-ansible-multiple_role-bug/roles/C/tasks/main.yml:2
ok: [localhost] => {
"msg": "C"
}

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