summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMartin Krizek <martin.krizek@gmail.com>2023-04-12 16:50:28 +0200
committerGitHub <noreply@github.com>2023-04-12 09:50:28 -0500
commitc0b452c73ca49ef44066fd37c769443b50fdde5f (patch)
tree153a9f5c725113db58bbd70560049b7d28578628 /test
parent39efd7a151aa1dff39a2b14c5c4bb780e8589623 (diff)
downloadansible-c0b452c73ca49ef44066fd37c769443b50fdde5f.tar.gz
Last handler defined runs, fix for roles (#79558) (#80495)
Fixes #73643 * clear_notification method and simplify ifs * Deduplicate code * Limit number of Templar creations * Fix sanity * Preserve handler callbacks order as they were notified (cherry picked from commit 09dd80b4ec7563caea095b4213794dd64ce8bed4)
Diffstat (limited to 'test')
-rw-r--r--test/integration/targets/handlers/roles/two_tasks_files_role/handlers/main.yml3
-rw-r--r--test/integration/targets/handlers/roles/two_tasks_files_role/tasks/main.yml3
-rw-r--r--test/integration/targets/handlers/roles/two_tasks_files_role/tasks/other.yml3
-rwxr-xr-xtest/integration/targets/handlers/runme.sh3
-rw-r--r--test/integration/targets/handlers/test_include_role_handler_once.yml20
5 files changed, 32 insertions, 0 deletions
diff --git a/test/integration/targets/handlers/roles/two_tasks_files_role/handlers/main.yml b/test/integration/targets/handlers/roles/two_tasks_files_role/handlers/main.yml
new file mode 100644
index 0000000000..3fd1318713
--- /dev/null
+++ b/test/integration/targets/handlers/roles/two_tasks_files_role/handlers/main.yml
@@ -0,0 +1,3 @@
+- name: handler
+ debug:
+ msg: handler ran
diff --git a/test/integration/targets/handlers/roles/two_tasks_files_role/tasks/main.yml b/test/integration/targets/handlers/roles/two_tasks_files_role/tasks/main.yml
new file mode 100644
index 0000000000..e6c12397bb
--- /dev/null
+++ b/test/integration/targets/handlers/roles/two_tasks_files_role/tasks/main.yml
@@ -0,0 +1,3 @@
+- name: main.yml task
+ command: echo
+ notify: handler
diff --git a/test/integration/targets/handlers/roles/two_tasks_files_role/tasks/other.yml b/test/integration/targets/handlers/roles/two_tasks_files_role/tasks/other.yml
new file mode 100644
index 0000000000..d90d46e00b
--- /dev/null
+++ b/test/integration/targets/handlers/roles/two_tasks_files_role/tasks/other.yml
@@ -0,0 +1,3 @@
+- name: other.yml task
+ command: echo
+ notify: handler
diff --git a/test/integration/targets/handlers/runme.sh b/test/integration/targets/handlers/runme.sh
index 76fc99d85b..cc0997a5c2 100755
--- a/test/integration/targets/handlers/runme.sh
+++ b/test/integration/targets/handlers/runme.sh
@@ -181,3 +181,6 @@ grep out.txt -e "ERROR! Using a block as a handler is not supported."
ansible-playbook test_block_as_handler-import.yml "$@" 2>&1 | tee out.txt
grep out.txt -e "ERROR! Using a block as a handler is not supported."
+
+ansible-playbook test_include_role_handler_once.yml -i inventory.handlers "$@" 2>&1 | tee out.txt
+[ "$(grep out.txt -ce 'handler ran')" = "1" ]
diff --git a/test/integration/targets/handlers/test_include_role_handler_once.yml b/test/integration/targets/handlers/test_include_role_handler_once.yml
new file mode 100644
index 0000000000..764aef6490
--- /dev/null
+++ b/test/integration/targets/handlers/test_include_role_handler_once.yml
@@ -0,0 +1,20 @@
+- hosts: localhost
+ gather_facts: false
+ tasks:
+ - name: "Call main entry point"
+ include_role:
+ name: two_tasks_files_role
+
+ - name: "Call main entry point again"
+ include_role:
+ name: two_tasks_files_role
+
+ - name: "Call other entry point"
+ include_role:
+ name: two_tasks_files_role
+ tasks_from: other
+
+ - name: "Call other entry point again"
+ include_role:
+ name: two_tasks_files_role
+ tasks_from: other