diff options
author | James Cammarata <jimi@sngx.net> | 2014-05-27 10:55:09 -0500 |
---|---|---|
committer | James Cammarata <jimi@sngx.net> | 2014-06-09 14:10:35 -0500 |
commit | b50a64b0a17b9153baced2b6db0b036bc3ccea99 (patch) | |
tree | e659dbd8fe8c9e8918a1a4c317bdb3e3d759770f /test | |
parent | adfbcb8760707dfb9eb2d81d1f7bc7d4764886a7 (diff) | |
download | ansible-b50a64b0a17b9153baced2b6db0b036bc3ccea99.tar.gz |
Correct issue of handlers running on all hosts incorrectly
Also adds an integration test to catch this bug in the future.
Fixes #7559
Diffstat (limited to 'test')
-rw-r--r-- | test/integration/roles/test_handlers/meta/main.yml | 3 | ||||
-rw-r--r-- | test/integration/roles/test_handlers/tasks/main.yml | 17 | ||||
-rw-r--r-- | test/integration/test_handlers.yml | 11 |
3 files changed, 23 insertions, 8 deletions
diff --git a/test/integration/roles/test_handlers/meta/main.yml b/test/integration/roles/test_handlers/meta/main.yml index 1050c23ce3..74d2c33354 100644 --- a/test/integration/roles/test_handlers/meta/main.yml +++ b/test/integration/roles/test_handlers/meta/main.yml @@ -1,3 +1,2 @@ -dependencies: - - prepare_tests +dependencies: [] diff --git a/test/integration/roles/test_handlers/tasks/main.yml b/test/integration/roles/test_handlers/tasks/main.yml index e788f51ea2..6f11768188 100644 --- a/test/integration/roles/test_handlers/tasks/main.yml +++ b/test/integration/roles/test_handlers/tasks/main.yml @@ -16,8 +16,23 @@ # You should have received a copy of the GNU General Public License # along with Ansible. If not, see <http://www.gnu.org/licenses/>. -- name: notify the handler + +- name: reset handler_called variable to false for all hosts + set_fact: + handler_called: False + +- name: notify the handler for host A only shell: echo notify: - set handler fact + when: inventory_hostname == 'A' + +- name: force handler execution now + meta: "flush_handlers" + +- debug: var=handler_called +- name: validate the handler only ran on one host + assert: + that: + - "inventory_hostname == 'A' and handler_called == True or handler_called == False" diff --git a/test/integration/test_handlers.yml b/test/integration/test_handlers.yml index dd766a9dea..6a5366408c 100644 --- a/test/integration/test_handlers.yml +++ b/test/integration/test_handlers.yml @@ -17,8 +17,9 @@ - "not hostvars[inventory_hostname]['handler1_called']" - "'handler2_called' in hostvars[inventory_hostname]" -#- hosts: testgroup -# gather_facts: False -# connection: local -# roles: -# - { role: test_handlers_meta } +- name: test handlers + hosts: testgroup + gather_facts: False + connection: local + roles: + - { role: test_handlers } |