mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-25 03:41:25 -07:00
Ziploader
* Ziploader proof of concept (jimi-c) * Cleanups to proof of concept ziploader branch: * python3 compatible base64 encoding * zipfile compression (still need to enable toggling this off for systems without zlib support in python) * Allow non-wildcard imports (still need to make this recusrsive so that we can have module_utils code that imports other module_utils code.) * Better tracebacks: module filename is kept and module_utils directory is kept so that tracebacks show the real filenames that the errors appear in. * Make sure we import modules that are used into the module_utils files that they are used in. * Set ansible version in a more pythonic way for ziploader than we were doing in module replacer * Make it possible to set the module compression as an inventory var This may be necessary on systems where python has been compiled without zlib compression. * Refactoring of module_common code: * module replacer only replaces values that make sense for that type of file (example: don't attempt to replace python imports if we're in a powershell module). * Implement configurable shebang support for ziploader wrapper * Implement client-side constants (for SELINUX_SPECIAL_FS and SYSLOG) via environment variable. * Remove strip_comments param as we're never going to use it (ruins line numbering) * Don't repeat ourselves about detecting REPLACER * Add an easy way to debug * Port test-module to the ziploader-aware modify_module() * strip comments and blank lines from the wrapper so we send less over the wire. * Comments cleanup * Remember to output write the module line itself in powershell modules * for line in lines strips the newlines so we have to add them back in
This commit is contained in:
parent
6a3670b1f0
commit
4b0aa1214c
32 changed files with 438 additions and 125 deletions
|
@ -267,6 +267,7 @@ class TestModuleUtilsBasic(unittest.TestCase):
|
|||
from ansible.module_utils import basic
|
||||
|
||||
basic.MODULE_COMPLEX_ARGS = '{}'
|
||||
basic.MODULE_CONSTANTS = '{}'
|
||||
am = basic.AnsibleModule(
|
||||
argument_spec=dict(),
|
||||
)
|
||||
|
@ -282,6 +283,7 @@ class TestModuleUtilsBasic(unittest.TestCase):
|
|||
|
||||
# should test ok
|
||||
basic.MODULE_COMPLEX_ARGS = '{"foo":"hello"}'
|
||||
basic.MODULE_CONSTANTS = '{}'
|
||||
am = basic.AnsibleModule(
|
||||
argument_spec = arg_spec,
|
||||
mutually_exclusive = mut_ex,
|
||||
|
@ -296,6 +298,7 @@ class TestModuleUtilsBasic(unittest.TestCase):
|
|||
|
||||
# fail, because a required param was not specified
|
||||
basic.MODULE_COMPLEX_ARGS = '{}'
|
||||
basic.MODULE_CONSTANTS = '{}'
|
||||
self.assertRaises(
|
||||
SystemExit,
|
||||
basic.AnsibleModule,
|
||||
|
@ -310,6 +313,7 @@ class TestModuleUtilsBasic(unittest.TestCase):
|
|||
|
||||
# fail because of mutually exclusive parameters
|
||||
basic.MODULE_COMPLEX_ARGS = '{"foo":"hello", "bar": "bad", "bam": "bad"}'
|
||||
basic.MODULE_CONSTANTS = '{}'
|
||||
self.assertRaises(
|
||||
SystemExit,
|
||||
basic.AnsibleModule,
|
||||
|
@ -324,6 +328,7 @@ class TestModuleUtilsBasic(unittest.TestCase):
|
|||
|
||||
# fail because a param required due to another param was not specified
|
||||
basic.MODULE_COMPLEX_ARGS = '{"bam":"bad"}'
|
||||
basic.MODULE_CONSTANTS = '{}'
|
||||
self.assertRaises(
|
||||
SystemExit,
|
||||
basic.AnsibleModule,
|
||||
|
@ -340,6 +345,7 @@ class TestModuleUtilsBasic(unittest.TestCase):
|
|||
from ansible.module_utils import basic
|
||||
|
||||
basic.MODULE_COMPLEX_ARGS = '{}'
|
||||
basic.MODULE_CONSTANTS = '{}'
|
||||
am = basic.AnsibleModule(
|
||||
argument_spec = dict(),
|
||||
)
|
||||
|
@ -389,6 +395,7 @@ class TestModuleUtilsBasic(unittest.TestCase):
|
|||
from ansible.module_utils import basic
|
||||
|
||||
basic.MODULE_COMPLEX_ARGS = '{}'
|
||||
basic.MODULE_CONSTANTS = '{}'
|
||||
am = basic.AnsibleModule(
|
||||
argument_spec = dict(),
|
||||
)
|
||||
|
@ -409,6 +416,7 @@ class TestModuleUtilsBasic(unittest.TestCase):
|
|||
from ansible.module_utils import basic
|
||||
|
||||
basic.MODULE_COMPLEX_ARGS = '{}'
|
||||
basic.MODULE_CONSTANTS = '{}'
|
||||
am = basic.AnsibleModule(
|
||||
argument_spec = dict(),
|
||||
)
|
||||
|
@ -423,6 +431,7 @@ class TestModuleUtilsBasic(unittest.TestCase):
|
|||
from ansible.module_utils import basic
|
||||
|
||||
basic.MODULE_COMPLEX_ARGS = '{}'
|
||||
basic.MODULE_CONSTANTS = '{}'
|
||||
am = basic.AnsibleModule(
|
||||
argument_spec = dict(),
|
||||
)
|
||||
|
@ -455,6 +464,7 @@ class TestModuleUtilsBasic(unittest.TestCase):
|
|||
from ansible.module_utils import basic
|
||||
|
||||
basic.MODULE_COMPLEX_ARGS = '{}'
|
||||
basic.MODULE_CONSTANTS = '{}'
|
||||
am = basic.AnsibleModule(
|
||||
argument_spec = dict(),
|
||||
)
|
||||
|
@ -491,6 +501,7 @@ class TestModuleUtilsBasic(unittest.TestCase):
|
|||
from ansible.module_utils import basic
|
||||
|
||||
basic.MODULE_COMPLEX_ARGS = '{}'
|
||||
basic.MODULE_CONSTANTS = '{}'
|
||||
am = basic.AnsibleModule(
|
||||
argument_spec = dict(),
|
||||
)
|
||||
|
@ -533,10 +544,11 @@ class TestModuleUtilsBasic(unittest.TestCase):
|
|||
from ansible.module_utils import basic
|
||||
|
||||
basic.MODULE_COMPLEX_ARGS = '{}'
|
||||
basic.SELINUX_SPECIAL_FS = 'nfs,nfsd,foos'
|
||||
basic.MODULE_CONSTANTS = '{"SELINUX_SPECIAL_FS": "nfs,nfsd,foos"}'
|
||||
am = basic.AnsibleModule(
|
||||
argument_spec = dict(),
|
||||
)
|
||||
print(am.constants)
|
||||
|
||||
def _mock_find_mount_point(path):
|
||||
if path.startswith('/some/path'):
|
||||
|
@ -574,6 +586,7 @@ class TestModuleUtilsBasic(unittest.TestCase):
|
|||
from ansible.module_utils import basic
|
||||
|
||||
basic.MODULE_COMPLEX_ARGS = '{}'
|
||||
basic.MODULE_CONSTANTS = '{}'
|
||||
am = basic.AnsibleModule(
|
||||
argument_spec = dict(),
|
||||
)
|
||||
|
@ -585,6 +598,7 @@ class TestModuleUtilsBasic(unittest.TestCase):
|
|||
from ansible.module_utils import basic
|
||||
|
||||
basic.MODULE_COMPLEX_ARGS = '{}'
|
||||
basic.MODULE_CONSTANTS = '{}'
|
||||
am = basic.AnsibleModule(
|
||||
argument_spec = dict(),
|
||||
)
|
||||
|
@ -600,6 +614,7 @@ class TestModuleUtilsBasic(unittest.TestCase):
|
|||
from ansible.module_utils import basic
|
||||
|
||||
basic.MODULE_COMPLEX_ARGS = '{}'
|
||||
basic.MODULE_CONSTANTS = '{}'
|
||||
am = basic.AnsibleModule(
|
||||
argument_spec = dict(),
|
||||
)
|
||||
|
@ -624,6 +639,7 @@ class TestModuleUtilsBasic(unittest.TestCase):
|
|||
from ansible.module_utils import basic
|
||||
|
||||
basic.MODULE_COMPLEX_ARGS = '{}'
|
||||
basic.MODULE_CONSTANTS = '{}'
|
||||
am = basic.AnsibleModule(
|
||||
argument_spec = dict(),
|
||||
)
|
||||
|
@ -669,6 +685,7 @@ class TestModuleUtilsBasic(unittest.TestCase):
|
|||
from ansible.module_utils import basic
|
||||
|
||||
basic.MODULE_COMPLEX_ARGS = '{}'
|
||||
basic.MODULE_CONSTANTS = '{}'
|
||||
am = basic.AnsibleModule(
|
||||
argument_spec = dict(),
|
||||
)
|
||||
|
@ -747,6 +764,7 @@ class TestModuleUtilsBasic(unittest.TestCase):
|
|||
from ansible.module_utils import basic
|
||||
|
||||
basic.MODULE_COMPLEX_ARGS = '{}'
|
||||
basic.MODULE_CONSTANTS = '{}'
|
||||
am = basic.AnsibleModule(
|
||||
argument_spec = dict(),
|
||||
)
|
||||
|
@ -835,6 +853,7 @@ class TestModuleUtilsBasic(unittest.TestCase):
|
|||
from ansible.module_utils import basic
|
||||
|
||||
basic.MODULE_COMPLEX_ARGS = '{}'
|
||||
basic.MODULE_CONSTANTS = '{}'
|
||||
am = basic.AnsibleModule(
|
||||
argument_spec = dict(),
|
||||
)
|
||||
|
@ -1013,6 +1032,7 @@ class TestModuleUtilsBasic(unittest.TestCase):
|
|||
from ansible.module_utils import basic
|
||||
|
||||
basic.MODULE_COMPLEX_ARGS = '{}'
|
||||
basic.MODULE_CONSTANTS = '{}'
|
||||
am = basic.AnsibleModule(
|
||||
argument_spec = dict(),
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue