mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-22 21:00:22 -07:00
Error if a module is found to shadow a reserved keyword (#34649)
* Error if a module is found to shadow a reserved keyword * Add test for shadowed module * Bring in functools.wraps for the decorator * Drop the decorator, make _find_plugin the real function, find_plugin now holds the shadow logic * Swap order of functions for bottom to top execution order * Only error for modules * Add test for loading a lookup plugin that shadows a keyword
This commit is contained in:
parent
d97952dbf4
commit
f1082af73f
8 changed files with 47 additions and 1 deletions
1
test/integration/targets/shadowed_module/aliases
Normal file
1
test/integration/targets/shadowed_module/aliases
Normal file
|
@ -0,0 +1 @@
|
|||
posix/ci/group3
|
1
test/integration/targets/shadowed_module/inventory
Symbolic link
1
test/integration/targets/shadowed_module/inventory
Symbolic link
|
@ -0,0 +1 @@
|
|||
../../inventory
|
0
test/integration/targets/shadowed_module/library/tags
Normal file
0
test/integration/targets/shadowed_module/library/tags
Normal file
6
test/integration/targets/shadowed_module/playbook.yml
Normal file
6
test/integration/targets/shadowed_module/playbook.yml
Normal file
|
@ -0,0 +1,6 @@
|
|||
---
|
||||
- hosts: localhost
|
||||
gather_facts: false
|
||||
tasks:
|
||||
- command: whoami
|
||||
tags: foo
|
|
@ -0,0 +1,6 @@
|
|||
---
|
||||
- hosts: localhost
|
||||
gather_facts: false
|
||||
tasks:
|
||||
- debug:
|
||||
msg: "{{ lookup('vars', 'inventory_hostname') }}"
|
14
test/integration/targets/shadowed_module/runme.sh
Executable file
14
test/integration/targets/shadowed_module/runme.sh
Executable file
|
@ -0,0 +1,14 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -ux
|
||||
|
||||
OUT=$(ansible-playbook playbook.yml -i inventory -e @../../integration_config.yml "$@" 2>&1 | grep 'ERROR! Module "tags" shadows the name of a reserved keyword.')
|
||||
|
||||
if [[ -z "$OUT" ]]; then
|
||||
echo "Fake tags module did not cause error"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# This playbook calls a lookup which shadows a keyword.
|
||||
# This is an ok situation, and should not error
|
||||
ansible-playbook playbook_lookup.yml -i inventory -e @../../integration_config.yml "$@"
|
Loading…
Add table
Add a link
Reference in a new issue