summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMartin Krizek <martin.krizek@gmail.com>2023-04-12 15:45:43 +0200
committerGitHub <noreply@github.com>2023-04-12 09:45:43 -0400
commit09dd80b4ec7563caea095b4213794dd64ce8bed4 (patch)
tree8c1751e551eb20c24c758ea71e25ae75dccdaccc /test
parent9026bc5d76a54d38d156e837f71178071eb60a64 (diff)
downloadansible-09dd80b4ec7563caea095b4213794dd64ce8bed4.tar.gz
Last handler defined runs, fix for roles (#79558)
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
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