mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Allow unicode transfer by not base64 encoding. Also: faster
This commit is contained in:
parent
227dfc17f3
commit
ce01c3f7e7
4 changed files with 9 additions and 6 deletions
|
@ -79,8 +79,9 @@ def boilerplate_module(modfile, args):
|
||||||
module_fh.close()
|
module_fh.close()
|
||||||
|
|
||||||
if included_boilerplate:
|
if included_boilerplate:
|
||||||
|
|
||||||
module_data = module_data.replace(module_common.REPLACER, module_common.MODULE_COMMON)
|
module_data = module_data.replace(module_common.REPLACER, module_common.MODULE_COMMON)
|
||||||
encoded_args = base64.b64encode(args)
|
encoded_args = "\"\"\"%s\"\"\"" % args.replace("\"","\\\"")
|
||||||
module_data = module_data.replace(module_common.REPLACER_ARGS, encoded_args)
|
module_data = module_data.replace(module_common.REPLACER_ARGS, encoded_args)
|
||||||
|
|
||||||
modfile2_path = os.path.expanduser("~/.ansible_module_generated")
|
modfile2_path = os.path.expanduser("~/.ansible_module_generated")
|
||||||
|
|
|
@ -22,7 +22,8 @@ MODULE_COMMON = """
|
||||||
|
|
||||||
# == BEGIN DYNAMICALLY INSERTED CODE ==
|
# == BEGIN DYNAMICALLY INSERTED CODE ==
|
||||||
|
|
||||||
MODULE_ARGS = "<<INCLUDE_ANSIBLE_MODULE_ARGS>>"
|
MODULE_ARGS = <<INCLUDE_ANSIBLE_MODULE_ARGS>>
|
||||||
|
|
||||||
BOOLEANS_TRUE = ['yes', 'on', '1', 'true', 1]
|
BOOLEANS_TRUE = ['yes', 'on', '1', 'true', 1]
|
||||||
BOOLEANS_FALSE = ['no', 'off', '0', 'false', 0]
|
BOOLEANS_FALSE = ['no', 'off', '0', 'false', 0]
|
||||||
BOOLEANS = BOOLEANS_TRUE + BOOLEANS_FALSE
|
BOOLEANS = BOOLEANS_TRUE + BOOLEANS_FALSE
|
||||||
|
@ -144,7 +145,7 @@ class AnsibleModule(object):
|
||||||
|
|
||||||
def _load_params(self):
|
def _load_params(self):
|
||||||
''' read the input and return a dictionary and the arguments string '''
|
''' read the input and return a dictionary and the arguments string '''
|
||||||
args = base64.b64decode(MODULE_ARGS)
|
args = MODULE_ARGS
|
||||||
items = shlex.split(args)
|
items = shlex.split(args)
|
||||||
params = {}
|
params = {}
|
||||||
for x in items:
|
for x in items:
|
||||||
|
|
|
@ -188,7 +188,7 @@ class Runner(object):
|
||||||
|
|
||||||
afd, afile = tempfile.mkstemp()
|
afd, afile = tempfile.mkstemp()
|
||||||
afo = os.fdopen(afd, 'w')
|
afo = os.fdopen(afd, 'w')
|
||||||
afo.write(data.encode("utf8"))
|
afo.write(data.encode('utf8'))
|
||||||
afo.flush()
|
afo.flush()
|
||||||
afo.close()
|
afo.close()
|
||||||
|
|
||||||
|
@ -700,7 +700,7 @@ class Runner(object):
|
||||||
if module_common.REPLACER in module_data:
|
if module_common.REPLACER in module_data:
|
||||||
is_new_style=True
|
is_new_style=True
|
||||||
module_data = module_data.replace(module_common.REPLACER, module_common.MODULE_COMMON)
|
module_data = module_data.replace(module_common.REPLACER, module_common.MODULE_COMMON)
|
||||||
encoded_args = base64.b64encode(utils.template(self.module_args, inject).encode('utf-8'))
|
encoded_args = "\"\"\"%s\"\"\"" % utils.template(self.module_args, inject).replace("\"","\\\"")
|
||||||
module_data = module_data.replace(module_common.REPLACER_ARGS, encoded_args)
|
module_data = module_data.replace(module_common.REPLACER_ARGS, encoded_args)
|
||||||
|
|
||||||
# use the correct python interpreter for the host
|
# use the correct python interpreter for the host
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
# (c) 2012, Michael DeHaan <michael.dehaan@gmail.com>, and others
|
# (c) 2012, Michael DeHaan <michael.dehaan@gmail.com>, and others
|
||||||
#
|
#
|
||||||
|
@ -84,7 +85,7 @@ class CommandModule(AnsibleModule):
|
||||||
|
|
||||||
def _load_params(self):
|
def _load_params(self):
|
||||||
''' read the input and return a dictionary and the arguments string '''
|
''' read the input and return a dictionary and the arguments string '''
|
||||||
args = base64.b64decode(MODULE_ARGS)
|
args = MODULE_ARGS
|
||||||
items = shlex.split(args)
|
items = shlex.split(args)
|
||||||
params = {}
|
params = {}
|
||||||
params['chdir'] = None
|
params['chdir'] = None
|
||||||
|
|
Loading…
Add table
Reference in a new issue