1
0
Fork 0
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:
James Cammarata 2014-02-24 14:24:25 -06:00
parent f03d6a67c8
commit 3b2d409906
4 changed files with 10 additions and 3 deletions

View file

@ -111,6 +111,7 @@ FILE_COMMON_ARGUMENTS=dict(
content = dict(),
backup = dict(),
force = dict(),
remote_src = dict(), # used by assemble
)
def get_platform():

View file

@ -57,7 +57,7 @@ class ActionModule(object):
src = options.get('src', None)
dest = options.get('dest', 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:
result = dict(failed=True, msg="src and dest are required")
@ -65,6 +65,8 @@ class ActionModule(object):
if remote_src:
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
path = self._assemble_from_fragments(src, delimiter)

View file

@ -107,7 +107,11 @@ def assemble_from_fragments(src_path, delimiter=None, compiled_regexp=None):
continue
fragment = "%s/%s" % (src_path, f)
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):
tmp.write(file(fragment).read())
delimit_me = True

View file

@ -60,7 +60,7 @@
- "result.md5sum == '4773eac67aba3f0be745876331c8a450'"
- 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
- name: assert the fragments were assembled without remote