summaryrefslogtreecommitdiffstats
path: root/test/integration/targets/plugin_loader/normal
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 16:04:21 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 16:04:21 +0000
commit8a754e0858d922e955e71b253c139e071ecec432 (patch)
tree527d16e74bfd1840c85efd675fdecad056c54107 /test/integration/targets/plugin_loader/normal
parentInitial commit. (diff)
downloadansible-core-upstream.tar.xz
ansible-core-upstream.zip
Adding upstream version 2.14.3.upstream/2.14.3upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'test/integration/targets/plugin_loader/normal')
-rw-r--r--test/integration/targets/plugin_loader/normal/action_plugins/self_referential.py29
-rw-r--r--test/integration/targets/plugin_loader/normal/filters.yml13
-rw-r--r--test/integration/targets/plugin_loader/normal/library/_underscore.py13
-rw-r--r--test/integration/targets/plugin_loader/normal/self_referential.yml5
-rw-r--r--test/integration/targets/plugin_loader/normal/underscore.yml15
5 files changed, 75 insertions, 0 deletions
diff --git a/test/integration/targets/plugin_loader/normal/action_plugins/self_referential.py b/test/integration/targets/plugin_loader/normal/action_plugins/self_referential.py
new file mode 100644
index 0000000..b4c8957
--- /dev/null
+++ b/test/integration/targets/plugin_loader/normal/action_plugins/self_referential.py
@@ -0,0 +1,29 @@
+# Copyright: Contributors to the Ansible project
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+from __future__ import (absolute_import, division, print_function)
+__metaclass__ = type
+
+from ansible.plugins.action import ActionBase
+
+import sys
+
+# reference our own module from sys.modules while it's being loaded to ensure the importer behaves properly
+try:
+ mod = sys.modules[__name__]
+except KeyError:
+ raise Exception(f'module {__name__} is not accessible via sys.modules, likely a pluginloader bug')
+
+
+class ActionModule(ActionBase):
+ TRANSFERS_FILES = False
+
+ def run(self, tmp=None, task_vars=None):
+ if task_vars is None:
+ task_vars = dict()
+
+ result = super(ActionModule, self).run(tmp, task_vars)
+ del tmp # tmp no longer has any effect
+
+ result['changed'] = False
+ result['msg'] = 'self-referential action loaded and ran successfully'
+ return result
diff --git a/test/integration/targets/plugin_loader/normal/filters.yml b/test/integration/targets/plugin_loader/normal/filters.yml
new file mode 100644
index 0000000..f9069be
--- /dev/null
+++ b/test/integration/targets/plugin_loader/normal/filters.yml
@@ -0,0 +1,13 @@
+- hosts: testhost
+ gather_facts: false
+ tasks:
+ - name: ensure filters work as shipped from core
+ assert:
+ that:
+ - a|flatten == [1, 2, 3, 4, 5]
+ - a|ternary('yes', 'no') == 'yes'
+ vars:
+ a:
+ - 1
+ - 2
+ - [3, 4, 5]
diff --git a/test/integration/targets/plugin_loader/normal/library/_underscore.py b/test/integration/targets/plugin_loader/normal/library/_underscore.py
new file mode 100644
index 0000000..7a416a6
--- /dev/null
+++ b/test/integration/targets/plugin_loader/normal/library/_underscore.py
@@ -0,0 +1,13 @@
+#!/usr/bin/python
+from __future__ import (absolute_import, division, print_function)
+__metaclass__ = type
+
+import json
+
+
+def main():
+ print(json.dumps(dict(changed=False, source='legacy_library_dir')))
+
+
+if __name__ == '__main__':
+ main()
diff --git a/test/integration/targets/plugin_loader/normal/self_referential.yml b/test/integration/targets/plugin_loader/normal/self_referential.yml
new file mode 100644
index 0000000..d3eed21
--- /dev/null
+++ b/test/integration/targets/plugin_loader/normal/self_referential.yml
@@ -0,0 +1,5 @@
+- hosts: testhost
+ gather_facts: false
+ tasks:
+ - name: ensure a self-referential action plugin loads properly
+ self_referential:
diff --git a/test/integration/targets/plugin_loader/normal/underscore.yml b/test/integration/targets/plugin_loader/normal/underscore.yml
new file mode 100644
index 0000000..fb5bbad
--- /dev/null
+++ b/test/integration/targets/plugin_loader/normal/underscore.yml
@@ -0,0 +1,15 @@
+- hosts: testhost
+ gather_facts: false
+ tasks:
+ - name: Load a deprecated module
+ underscore:
+ register: res
+
+ - name: Load a deprecated module that is a symlink
+ symlink:
+ register: sym
+
+ - assert:
+ that:
+ - res.source == 'legacy_library_dir'
+ - sym.source == 'legacy_library_dir'