|
30 | 30 | from io import BytesIO
|
31 | 31 |
|
32 | 32 | # from Ansible
|
33 |
| -from ansible import __version__ |
| 33 | +from ansible.release import __version__, __author__ |
34 | 34 | from ansible import constants as C
|
35 | 35 | from ansible.errors import AnsibleError
|
36 | 36 | from ansible.utils.unicode import to_bytes, to_unicode
|
@@ -533,6 +533,7 @@ def _find_snippet_imports(module_name, module_data, module_path, module_args, ta
|
533 | 533 | constants = dict(
|
534 | 534 | SELINUX_SPECIAL_FS=C.DEFAULT_SELINUX_SPECIAL_FS,
|
535 | 535 | SYSLOG_FACILITY=_get_facility(task_vars),
|
| 536 | + ANSIBLE_VERSION=__version__, |
536 | 537 | )
|
537 | 538 | params = dict(ANSIBLE_MODULE_ARGS=module_args,
|
538 | 539 | ANSIBLE_MODULE_CONSTANTS=constants,
|
@@ -562,8 +563,8 @@ def _find_snippet_imports(module_name, module_data, module_path, module_args, ta
|
562 | 563 | # Create the module zip data
|
563 | 564 | zipoutput = BytesIO()
|
564 | 565 | zf = zipfile.ZipFile(zipoutput, mode='w', compression=compression_method)
|
565 |
| - zf.writestr('ansible/__init__.py', b''.join((b"__version__ = '", to_bytes(__version__), b"'\n"))) |
566 |
| - zf.writestr('ansible/module_utils/__init__.py', b'') |
| 566 | + zf.writestr('ansible/__init__.py', b'from pkgutil import extend_path\n__path__=extend_path(__path__,__name__)\ntry:\n from ansible.release import __version__,__author__\nexcept ImportError:\n __version__="' + to_bytes(__version__) + b'"\n __author__="' + to_bytes(__author__) + b'"\n') |
| 567 | + zf.writestr('ansible/module_utils/__init__.py', b'from pkgutil import extend_path\n__path__=extend_path(__path__,__name__)\n') |
567 | 568 |
|
568 | 569 | zf.writestr('ansible_module_%s.py' % module_name, module_data)
|
569 | 570 |
|
|
0 commit comments