diff options
author | Martin Krizek <martin.krizek@gmail.com> | 2023-02-16 16:30:23 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-16 09:30:23 -0600 |
commit | 02d9336b320c39de652667069b7ecadd8ed36fc9 (patch) | |
tree | a187aee039a048dd8438687f8aa09ac27f94bc29 /test/integration/targets/handlers | |
parent | a082726ef28c3d6763259aa42d9c1191e2a0f77e (diff) | |
download | ansible-02d9336b320c39de652667069b7ecadd8ed36fc9.tar.gz |
Make using blocks as handlers a parser error (#79993) (#80010)
Fixes #79968
(cherry picked from commit bd329dc54329a126056723311abd7442ed6a0389)
Diffstat (limited to 'test/integration/targets/handlers')
5 files changed, 45 insertions, 0 deletions
diff --git a/test/integration/targets/handlers/runme.sh b/test/integration/targets/handlers/runme.sh index 887a82db47..76fc99d85b 100755 --- a/test/integration/targets/handlers/runme.sh +++ b/test/integration/targets/handlers/runme.sh @@ -172,3 +172,12 @@ grep out.txt -e "handler ran" grep out.txt -e "after flush" ansible-playbook 79776.yml -i inventory.handlers "$@" + +ansible-playbook test_block_as_handler.yml "$@" 2>&1 | tee out.txt +grep out.txt -e "ERROR! Using a block as a handler is not supported." + +ansible-playbook test_block_as_handler-include.yml "$@" 2>&1 | tee out.txt +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." diff --git a/test/integration/targets/handlers/test_block_as_handler-import.yml b/test/integration/targets/handlers/test_block_as_handler-import.yml new file mode 100644 index 0000000000..ad6bb0d595 --- /dev/null +++ b/test/integration/targets/handlers/test_block_as_handler-import.yml @@ -0,0 +1,7 @@ +- hosts: localhost + gather_facts: false + tasks: + - debug: + handlers: + - name: handler + import_tasks: test_block_as_handler-include_import-handlers.yml diff --git a/test/integration/targets/handlers/test_block_as_handler-include.yml b/test/integration/targets/handlers/test_block_as_handler-include.yml new file mode 100644 index 0000000000..5b03b0a82e --- /dev/null +++ b/test/integration/targets/handlers/test_block_as_handler-include.yml @@ -0,0 +1,8 @@ +- hosts: localhost + gather_facts: false + tasks: + - command: echo + notify: handler + handlers: + - name: handler + include_tasks: test_block_as_handler-include_import-handlers.yml diff --git a/test/integration/targets/handlers/test_block_as_handler-include_import-handlers.yml b/test/integration/targets/handlers/test_block_as_handler-include_import-handlers.yml new file mode 100644 index 0000000000..61c058ba67 --- /dev/null +++ b/test/integration/targets/handlers/test_block_as_handler-include_import-handlers.yml @@ -0,0 +1,8 @@ +- name: handler + block: + - name: due to how handlers are implemented, this is correct as it is equivalent to an implicit block + debug: + - name: this is a parser error, blocks as handlers are not supported + block: + - name: handler in a nested block + debug: diff --git a/test/integration/targets/handlers/test_block_as_handler.yml b/test/integration/targets/handlers/test_block_as_handler.yml new file mode 100644 index 0000000000..bd4f5b991e --- /dev/null +++ b/test/integration/targets/handlers/test_block_as_handler.yml @@ -0,0 +1,13 @@ +- hosts: localhost + gather_facts: false + tasks: + - debug: + handlers: + - name: handler + block: + - name: due to how handlers are implemented, this is correct as it is equivalent to an implicit block + debug: + - name: this is a parser error, blocks as handlers are not supported + block: + - name: handler in a nested block + debug: |