diff options
Diffstat (limited to '')
6 files changed, 53 insertions, 0 deletions
diff --git a/test/integration/targets/old_style_vars_plugins/aliases b/test/integration/targets/old_style_vars_plugins/aliases new file mode 100644 index 0000000..8278ec8 --- /dev/null +++ b/test/integration/targets/old_style_vars_plugins/aliases @@ -0,0 +1,2 @@ +shippable/posix/group3 +context/controller diff --git a/test/integration/targets/old_style_vars_plugins/deprecation_warning/vars.py b/test/integration/targets/old_style_vars_plugins/deprecation_warning/vars.py new file mode 100644 index 0000000..d5c9a42 --- /dev/null +++ b/test/integration/targets/old_style_vars_plugins/deprecation_warning/vars.py @@ -0,0 +1,8 @@ +from ansible.plugins.vars import BaseVarsPlugin + + +class VarsModule(BaseVarsPlugin): + REQUIRES_WHITELIST = False + + def get_vars(self, loader, path, entities): + return {} diff --git a/test/integration/targets/old_style_vars_plugins/runme.sh b/test/integration/targets/old_style_vars_plugins/runme.sh new file mode 100755 index 0000000..4cd1916 --- /dev/null +++ b/test/integration/targets/old_style_vars_plugins/runme.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash + +set -eux + +export ANSIBLE_VARS_PLUGINS=./vars_plugins + +# Test vars plugin without REQUIRES_ENABLED class attr and vars plugin with REQUIRES_ENABLED = False run by default +[ "$(ansible-inventory -i localhost, --list --yaml all "$@" | grep -Ec '(implicitly|explicitly)_auto_enabled')" = "2" ] + +# Test vars plugin with REQUIRES_ENABLED=True only runs when enabled +[ "$(ansible-inventory -i localhost, --list --yaml all "$@" | grep -Ec 'require_enabled')" = "0" ] +export ANSIBLE_VARS_ENABLED=require_enabled +[ "$(ansible-inventory -i localhost, --list --yaml all "$@" | grep -c 'require_enabled')" = "1" ] + +# Test the deprecated class attribute +export ANSIBLE_VARS_PLUGINS=./deprecation_warning +WARNING="The VarsModule class variable 'REQUIRES_WHITELIST' is deprecated. Use 'REQUIRES_ENABLED' instead." +ANSIBLE_DEPRECATION_WARNINGS=True ANSIBLE_NOCOLOR=True ANSIBLE_FORCE_COLOR=False \ + ansible-inventory -i localhost, --list all 2> err.txt +ansible localhost -m debug -a "msg={{ lookup('file', 'err.txt') | regex_replace('\n', '') }}" | grep "$WARNING" diff --git a/test/integration/targets/old_style_vars_plugins/vars_plugins/auto_enabled.py b/test/integration/targets/old_style_vars_plugins/vars_plugins/auto_enabled.py new file mode 100644 index 0000000..a91d94d --- /dev/null +++ b/test/integration/targets/old_style_vars_plugins/vars_plugins/auto_enabled.py @@ -0,0 +1,8 @@ +from ansible.plugins.vars import BaseVarsPlugin + + +class VarsModule(BaseVarsPlugin): + REQUIRES_ENABLED = False + + def get_vars(self, loader, path, entities): + return {'explicitly_auto_enabled': True} diff --git a/test/integration/targets/old_style_vars_plugins/vars_plugins/implicitly_auto_enabled.py b/test/integration/targets/old_style_vars_plugins/vars_plugins/implicitly_auto_enabled.py new file mode 100644 index 0000000..4f407b4 --- /dev/null +++ b/test/integration/targets/old_style_vars_plugins/vars_plugins/implicitly_auto_enabled.py @@ -0,0 +1,7 @@ +from ansible.plugins.vars import BaseVarsPlugin + + +class VarsModule(BaseVarsPlugin): + + def get_vars(self, loader, path, entities): + return {'implicitly_auto_enabled': True} diff --git a/test/integration/targets/old_style_vars_plugins/vars_plugins/require_enabled.py b/test/integration/targets/old_style_vars_plugins/vars_plugins/require_enabled.py new file mode 100644 index 0000000..a251447 --- /dev/null +++ b/test/integration/targets/old_style_vars_plugins/vars_plugins/require_enabled.py @@ -0,0 +1,8 @@ +from ansible.plugins.vars import BaseVarsPlugin + + +class VarsModule(BaseVarsPlugin): + REQUIRES_ENABLED = True + + def get_vars(self, loader, path, entities): + return {'require_enabled': True} |