mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Fixing several bugs in assemble and updating tests
Bugfixes: * the remote_src param was not being converted to a boolean correctly, resulting in it never being used by the module as the default behavior was remote_src=True (issue #5581) * the remote_src param was not listed in the generic file params, leading to a failure when the above bug regarding remote_src was fixed * the delimiter should always end with a newline to ensure that the file fragments do not run together on one line Fixes #5581
This commit is contained in:
parent
f03d6a67c8
commit
3b2d409906
4 changed files with 10 additions and 3 deletions
|
@ -111,6 +111,7 @@ FILE_COMMON_ARGUMENTS=dict(
|
||||||
content = dict(),
|
content = dict(),
|
||||||
backup = dict(),
|
backup = dict(),
|
||||||
force = dict(),
|
force = dict(),
|
||||||
|
remote_src = dict(), # used by assemble
|
||||||
)
|
)
|
||||||
|
|
||||||
def get_platform():
|
def get_platform():
|
||||||
|
|
|
@ -57,7 +57,7 @@ class ActionModule(object):
|
||||||
src = options.get('src', None)
|
src = options.get('src', None)
|
||||||
dest = options.get('dest', None)
|
dest = options.get('dest', None)
|
||||||
delimiter = options.get('delimiter', None)
|
delimiter = options.get('delimiter', None)
|
||||||
remote_src = options.get('remote_src', True)
|
remote_src = utils.boolean(options.get('remote_src', 'yes'))
|
||||||
|
|
||||||
if src is None or dest is None:
|
if src is None or dest is None:
|
||||||
result = dict(failed=True, msg="src and dest are required")
|
result = dict(failed=True, msg="src and dest are required")
|
||||||
|
@ -65,6 +65,8 @@ class ActionModule(object):
|
||||||
|
|
||||||
if remote_src:
|
if remote_src:
|
||||||
return self.runner._execute_module(conn, tmp, 'assemble', module_args, inject=inject, complex_args=complex_args)
|
return self.runner._execute_module(conn, tmp, 'assemble', module_args, inject=inject, complex_args=complex_args)
|
||||||
|
elif '_original_file' in inject:
|
||||||
|
src = utils.path_dwim_relative(inject['_original_file'], 'files', src, self.runner.basedir)
|
||||||
|
|
||||||
# Does all work assembling the file
|
# Does all work assembling the file
|
||||||
path = self._assemble_from_fragments(src, delimiter)
|
path = self._assemble_from_fragments(src, delimiter)
|
||||||
|
|
|
@ -107,7 +107,11 @@ def assemble_from_fragments(src_path, delimiter=None, compiled_regexp=None):
|
||||||
continue
|
continue
|
||||||
fragment = "%s/%s" % (src_path, f)
|
fragment = "%s/%s" % (src_path, f)
|
||||||
if delimit_me and delimiter:
|
if delimit_me and delimiter:
|
||||||
tmp.write("%s\n" % delimiter)
|
tmp.write(delimiter)
|
||||||
|
# always make sure there's a newline after the
|
||||||
|
# delimiter, so lines don't run together
|
||||||
|
if delimiter[-1] != '\n':
|
||||||
|
tmp.write('\n')
|
||||||
if os.path.isfile(fragment):
|
if os.path.isfile(fragment):
|
||||||
tmp.write(file(fragment).read())
|
tmp.write(file(fragment).read())
|
||||||
delimit_me = True
|
delimit_me = True
|
||||||
|
|
|
@ -60,7 +60,7 @@
|
||||||
- "result.md5sum == '4773eac67aba3f0be745876331c8a450'"
|
- "result.md5sum == '4773eac67aba3f0be745876331c8a450'"
|
||||||
|
|
||||||
- name: test assemble with remote_src=False
|
- name: test assemble with remote_src=False
|
||||||
assemble: src="{{output_dir}}/src" dest="{{output_dir}}/assembled4" remote_src=False
|
assemble: src="./" dest="{{output_dir}}/assembled4" remote_src=no
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: assert the fragments were assembled without remote
|
- name: assert the fragments were assembled without remote
|
||||||
|
|
Loading…
Reference in a new issue