Issue 1:
Summary

We would like to have a paramaterized role to configure a service and have a handler that restarts the service using parameters that are passed into the role.

A real world example is a role that installs supervisor that takes a path to a virtual environment and config parameters as parameters. In that case we want to notify a restart on the service using the parameters for each time it is called. This seems to work ok in 1.3, it breaks in 1.4.

Simple example to illustrate the issue:

test/tasks/main.yml:

- shell: echo "test - {{ test_param }}"
notify: test handler

test/handlers/main.yml:

- name: test handler
debug: msg="handler {{ test_param }}"

play:

- hosts: all
roles:
- { role: test, test_param: "first call to test" }
- { role: test, test_param: "second call to test" }

ansible 1.3 output:

This seems to work as expected

TASK: [shell echo "test - first call to test"] ********************************
changed: [localhost]

TASK: [shell echo "test - second call to test"] *******************************
changed: [localhost]

NOTIFIED: [test handler] ******************************************************
ok: [localhost] => {"item": "", "msg": "handler first call to test"}

NOTIFIED: [test handler] ******************************************************
ok: [localhost] => {"item": "", "msg": "handler second call to test"}

ansible-playbook 1.4 (devel f347133) output:

Note that only the handler was triggered only once for the first call. This can be an issue when you call a role with parameters where one of the parameters is used in the notifier (such as a service configuration file location, and a restart handler)

TASK: [test | shell echo "test - first call to test"] *************************
changed: [localhost]

TASK: [test | shell echo "test - second call to test"] ************************
changed: [localhost]

NOTIFIED: [test | test handler] ***********************************************
ok: [localhost] => {
"item": "",
"msg": "handler first call to test"
}

Changing test/tasks/main.yml to flush its handlers seems to have issues in both versions:

test/tasks/main.yml:

- shell: echo "test - {{ test_param }}"
notify: test handler

- meta: flush_handlers

ansible 1.3:

Note that both handlers for both parameters are flushing twice.

TASK: [shell echo "test - first call to test"] ********************************
changed: [localhost]

NOTIFIED: [test handler] ******************************************************
ok: [localhost] => {"item": "", "msg": "handler first call to test"}

NOTIFIED: [test handler] ******************************************************
ok: [localhost] => {"item": "", "msg": "handler second call to test"}

TASK: [shell echo "test - second call to test"] *******************************
changed: [localhost]

NOTIFIED: [test handler] ******************************************************
ok: [localhost] => {"item": "", "msg": "handler first call to test"}

NOTIFIED: [test handler] ******************************************************
ok: [localhost] => {"item": "", "msg": "handler second call to test"}

ansible 1.4 (devel f347133) output:

In this case when the second call to test.yml flushes its handler it uses the first definition of {{ test_param }}, not the second.

TASK: [test | shell echo "test - first call to test"] *************************
changed: [localhost]

NOTIFIED: [test | test handler] ***********************************************
ok: [localhost] => {
"item": "",
"msg": "handler first call to test"
}

TASK: [test | shell echo "test - second call to test"] ************************
changed: [localhost]

NOTIFIED: [test | test handler] ***********************************************
ok: [localhost] => {
"item": "",
"msg": "handler first call to test"
}

Issue 2:
Since I recently updated my Ansible installation repository, Ansible overrides default variables where it should not. If I call a sub role as dependency of a 'parent' role twice, but the last time with overriding a default variable, the variable was also overridden on the first call. Here is a tiny example setup (I omitted the starting --- in every file):

sub_role/defaults/main.yml

myvar: "first call"

sub_role/tasks/main.yml

- debug: var=myvar

parent_role/meta/main.yml

dependencies:
- { role: sub_role }
- { role: sub_role, myvar: "second call" }

Now executing the parent_role leads to following wrong result:

TASK [sub_role : debug] ********************************************************
ok: [localhost] => {
"myval": "second call"
}

TASK [sub_role : debug] ********************************************************
ok: [localhost] => {
"myval": "second call"
}

Can you see the error? On the first call, the output of myval should be first call and not second call. Because of recent changes Ansible seems to interpret all role variables, starting with the first definition and ignoring omitted definitions.