From 3edac76e1b932b05acfca5961eea95323c0e8c8b Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bonicoli Date: Thu, 16 Jul 2015 03:54:12 +0200 Subject: [PATCH] tests: check that handlers are able to use 'include' --- test/integration/targets/handlers/handlers.yml | 2 ++ .../roles/test_handlers_include/handlers/main.yml | 1 + .../roles/test_handlers_include/tasks/main.yml | 4 ++++ test/integration/targets/handlers/runme.sh | 6 ++++++ .../targets/handlers/test_handlers_include.yml | 14 ++++++++++++++ 5 files changed, 27 insertions(+) create mode 100644 test/integration/targets/handlers/handlers.yml create mode 100644 test/integration/targets/handlers/roles/test_handlers_include/handlers/main.yml create mode 100644 test/integration/targets/handlers/roles/test_handlers_include/tasks/main.yml create mode 100644 test/integration/targets/handlers/test_handlers_include.yml diff --git a/test/integration/targets/handlers/handlers.yml b/test/integration/targets/handlers/handlers.yml new file mode 100644 index 0000000000..aed75bd27d --- /dev/null +++ b/test/integration/targets/handlers/handlers.yml @@ -0,0 +1,2 @@ +- name: test handler + debug: msg="handler called" diff --git a/test/integration/targets/handlers/roles/test_handlers_include/handlers/main.yml b/test/integration/targets/handlers/roles/test_handlers_include/handlers/main.yml new file mode 100644 index 0000000000..abe01be4ba --- /dev/null +++ b/test/integration/targets/handlers/roles/test_handlers_include/handlers/main.yml @@ -0,0 +1 @@ +- include: handlers.yml diff --git a/test/integration/targets/handlers/roles/test_handlers_include/tasks/main.yml b/test/integration/targets/handlers/roles/test_handlers_include/tasks/main.yml new file mode 100644 index 0000000000..84f0a583fa --- /dev/null +++ b/test/integration/targets/handlers/roles/test_handlers_include/tasks/main.yml @@ -0,0 +1,4 @@ +- name: 'main task' + debug: msg='main task' + changed_when: True + notify: test handler diff --git a/test/integration/targets/handlers/runme.sh b/test/integration/targets/handlers/runme.sh index 48dfd8368b..b1af33b335 100755 --- a/test/integration/targets/handlers/runme.sh +++ b/test/integration/targets/handlers/runme.sh @@ -34,3 +34,9 @@ ansible-playbook test_handlers.yml -i inventory.handlers -v "$@" --tags scenario # Forcing false in play, which overrides command line [ "$(ansible-playbook test_force_handlers.yml -i inventory.handlers -v "$@" --tags force_false_in_play --force-handlers \ | egrep -o CALLED_HANDLER_. | sort | uniq | xargs)" = "CALLED_HANDLER_B" ] + +[ "$(ansible-playbook test_handlers_include.yml -i ../../inventory -v "$@" --tags playbook_include_handlers \ +| egrep -o 'RUNNING HANDLER \[.*?]')" = "RUNNING HANDLER [test handler]" ] + +[ "$(ansible-playbook test_handlers_include.yml -i ../../inventory -v "$@" --tags role_include_handlers \ +| egrep -o 'RUNNING HANDLER \[test_handlers_include : .*?]')" = "RUNNING HANDLER [test_handlers_include : test handler]" ] diff --git a/test/integration/targets/handlers/test_handlers_include.yml b/test/integration/targets/handlers/test_handlers_include.yml new file mode 100644 index 0000000000..5514fc1094 --- /dev/null +++ b/test/integration/targets/handlers/test_handlers_include.yml @@ -0,0 +1,14 @@ +- name: verify that play can include handler + hosts: testhost + tasks: + - debug: msg="main task" + changed_when: True + notify: test handler + tags: ['playbook_include_handlers'] + handlers: + - include: handlers.yml + +- name: verify that role can include handler + hosts: testhost + roles: + - { role: test_handlers_include, tags: ['role_include_handlers'] }