From 4620ccb5065dbe463042f719e1250289f4b6db45 Mon Sep 17 00:00:00 2001 From: Alex Willmer Date: Fri, 28 Jul 2023 15:52:21 +0100 Subject: [PATCH] WIP --- .ci/azure-pipelines.yml | 8 ++--- tests/ansible/integration/all.yml | 2 ++ tests/ansible/integration/responder/all.yml | 1 + .../ansible/integration/responder/imports.yml | 23 ++++++++++++ .../lib/modules/mitogen_plain_old_add.py | 36 +++++++++++++++++++ tests/ansible/run_ansible_playbook.py | 2 ++ 6 files changed, 66 insertions(+), 6 deletions(-) create mode 100644 tests/ansible/integration/responder/all.yml create mode 100644 tests/ansible/integration/responder/imports.yml create mode 100644 tests/ansible/lib/modules/mitogen_plain_old_add.py diff --git a/.ci/azure-pipelines.yml b/.ci/azure-pipelines.yml index 4513ae9f5..073095b8a 100644 --- a/.ci/azure-pipelines.yml +++ b/.ci/azure-pipelines.yml @@ -33,13 +33,9 @@ jobs: # NOTE: this hangs when ran in Ubuntu 18.04 Van_27_210: - tox.env: py27-mode_localhost-ansible2.10 - STRATEGY: linear - ANSIBLE_SKIP_TAGS: resource_intensive + tox.env: py27-mode_localhost-ansible2.10-strategy_linear Van_27_4: - tox.env: py27-mode_localhost-ansible4 - STRATEGY: linear - ANSIBLE_SKIP_TAGS: resource_intensive + tox.env: py27-mode_localhost-ansible4-strategy_linear - job: Linux pool: diff --git a/tests/ansible/integration/all.yml b/tests/ansible/integration/all.yml index ac196584e..47d98cce0 100644 --- a/tests/ansible/integration/all.yml +++ b/tests/ansible/integration/all.yml @@ -29,6 +29,8 @@ tags: playbook_semantics - import_playbook: process/all.yml tags: process +- import_playbook: responder/all.yml + tags: responder - import_playbook: runner/all.yml tags: runner - import_playbook: ssh/all.yml diff --git a/tests/ansible/integration/responder/all.yml b/tests/ansible/integration/responder/all.yml new file mode 100644 index 000000000..5846bcd99 --- /dev/null +++ b/tests/ansible/integration/responder/all.yml @@ -0,0 +1 @@ +- import_playbook: imports.yml diff --git a/tests/ansible/integration/responder/imports.yml b/tests/ansible/integration/responder/imports.yml new file mode 100644 index 000000000..42edb8f32 --- /dev/null +++ b/tests/ansible/integration/responder/imports.yml @@ -0,0 +1,23 @@ +- name: integration/responder/imports.yml + hosts: test-targets + tasks: + - meta: end_play + when: not is_mitogen + + - name: Import pure Python module via Ansible module + mitogen_plain_old_add: + x: 2 + y: 2 + register: mitogen_plain_old_add_result + + - name: Import binary module via Responder + custom_python_run_script: + script: | + import lxml + register: binary_module_result + + - name: Import missing module via Responder + custom_python_run_script: + script: | + import does_not_exist + register: missing_module_result diff --git a/tests/ansible/lib/modules/mitogen_plain_old_add.py b/tests/ansible/lib/modules/mitogen_plain_old_add.py new file mode 100644 index 000000000..19f3b9ee5 --- /dev/null +++ b/tests/ansible/lib/modules/mitogen_plain_old_add.py @@ -0,0 +1,36 @@ +#!/usr/bin/env python + +DOCUMENTATION = ''' +module: mitogen_plain_old_add +options: + x: {type: int, required: true} + y: {type: int, required: true} +author: + - Alex Willmer (@moreati) +''' + +RETURN = ''' +total: {type: int, returned: always, sample: 42} +''' + +from ansible.module_utils.basic import AnsibleModule + +import plain_old_module + +def main(): + module = AnsibleModule( + argument_spec={ + 'x': {'type': int, 'required': True}, + 'x': {'type': int, 'required': True}, + }, + supports_check_mode=True, + ) + result = { + 'changed': False, + 'total': plain_old_module.add(module.params['x'], module.params['y']), + } + module.exit_json(**result) + + +if __name__ == '__main__': + main() diff --git a/tests/ansible/run_ansible_playbook.py b/tests/ansible/run_ansible_playbook.py index 04c0c9db1..bda9ca151 100755 --- a/tests/ansible/run_ansible_playbook.py +++ b/tests/ansible/run_ansible_playbook.py @@ -35,6 +35,8 @@ os.environ['PATH'], ) +os.environ['PYTHONPATH'] = os.path.join(GIT_BASEDIR, 'tests', 'data') + extra = { 'is_mitogen': os.environ.get('ANSIBLE_STRATEGY', '').startswith('mitogen'), 'git_basedir': GIT_BASEDIR,