Action module xross coll (#68080)

* added test to verify xrs collection action/module

* added to runme

* sanity fixes

* corrected name

* avoid windoez
This commit is contained in:
Brian Coca 2020-03-25 11:57:53 -04:00 committed by GitHub
parent 6acaf9fa95
commit ecd66a6a6e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 106 additions and 1 deletions

View file

@ -0,0 +1,29 @@
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
from ansible.plugins.action import ActionBase
class ActionModule(ActionBase):
def run(self, tmp=None, task_vars=None):
''' handler for file transfer operations '''
if task_vars is None:
task_vars = dict()
result = super(ActionModule, self).run(tmp, task_vars)
if result.get('skipped'):
return result
module_args = self._task.args.copy()
result.update(
self._execute_module(
module_name='me.mycoll2.module1',
module_args=module_args,
task_vars=task_vars,
)
)
return result

View file

@ -0,0 +1,24 @@
#!/usr/bin/python
from __future__ import absolute_import, division, print_function
__metaclass__ = type
ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ['stableinterface'],
'supported_by': 'core'}
DOCUMENTATION = '''
---
module: action1
short_description: Action Test module
description:
- Action Test module
author:
- Ansible Core Team
'''
EXAMPLES = '''
'''
RETURN = '''
'''

View file

@ -0,0 +1,43 @@
#!/usr/bin/python
from __future__ import absolute_import, division, print_function
__metaclass__ = type
ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ['stableinterface'],
'supported_by': 'core'}
DOCUMENTATION = '''
---
module: module1
short_description: module1 Test module
description:
- module1 Test module
author:
- Ansible Core Team
'''
EXAMPLES = '''
'''
RETURN = '''
'''
from ansible.module_utils.basic import AnsibleModule
def main():
module = AnsibleModule(
argument_spec=dict(
desc=dict(type='str'),
),
)
results = dict(msg="you just ran me.mycoll2.module1", desc=module.params.get('desc'))
module.exit_json(**results)
if __name__ == '__main__':
main()

View file

@ -0,0 +1,5 @@
- hosts: testhost
gather_facts: false
tasks:
- name: run action that invokes module from another collection
me.mycoll1.action1: desc="this should run me.mycoll2.module1"

View file

@ -36,9 +36,13 @@ else
ansible-playbook -i "${INVENTORY_PATH}" collection_root_user/ansible_collections/testns/testcoll/playbooks/default_collection_playbook.yml
fi
# run test playbook
# run test playbooks
ansible-playbook -i "${INVENTORY_PATH}" -i ./a.statichost.yml -v "${TEST_PLAYBOOK}" "$@"
if [[ ${INVENTORY_PATH} != *.winrm ]]; then
ansible-playbook -i "${INVENTORY_PATH}" -i ./a.statichost.yml -v invocation_tests.yml "$@"
fi
# test adjacent with --playbook-dir
export ANSIBLE_COLLECTIONS_PATHS=''
ANSIBLE_INVENTORY_ANY_UNPARSED_IS_FAILED=1 ansible-inventory -i a.statichost.yml --list --export --playbook-dir=. -v "$@"