Commit a9787290 by James Cammarata

Fixed a bug in the delimiter change for the assemble module

parent bcf9a75d
...@@ -19,6 +19,7 @@ New modules: ...@@ -19,6 +19,7 @@ New modules:
Misc changes: Misc changes:
* Added a `delimiter` field to the assemble module.
* Added `ansible_env` to the list of facts returned by the setup module. * Added `ansible_env` to the list of facts returned by the setup module.
* Added `state=touch` to the file module, which functions similarly to the command-line version of `touch`. * Added `state=touch` to the file module, which functions similarly to the command-line version of `touch`.
* Added a -vvvv level, which will show SSH client debugging information in the event of a failure. * Added a -vvvv level, which will show SSH client debugging information in the event of a failure.
......
...@@ -76,14 +76,14 @@ EXAMPLES = ''' ...@@ -76,14 +76,14 @@ EXAMPLES = '''
# =========================================== # ===========================================
# Support method # Support method
def assemble_from_fragments(src_path, delimiter=''): def assemble_from_fragments(src_path, delimiter=None):
''' assemble a file from a directory of fragments ''' ''' assemble a file from a directory of fragments '''
tmpfd, temp_path = tempfile.mkstemp() tmpfd, temp_path = tempfile.mkstemp()
tmp = os.fdopen(tmpfd,'w') tmp = os.fdopen(tmpfd,'w')
delimit_me = False delimit_me = False
for f in sorted(os.listdir(src_path)): for f in sorted(os.listdir(src_path)):
fragment = "%s/%s" % (src_path, f) fragment = "%s/%s" % (src_path, f)
if delimit_me: if delimit_me and delimiter:
tmp.write(delimiter) tmp.write(delimiter)
if os.path.isfile(fragment): if os.path.isfile(fragment):
tmp.write(file(fragment).read()) tmp.write(file(fragment).read())
...@@ -107,13 +107,13 @@ def main(): ...@@ -107,13 +107,13 @@ def main():
add_file_common_args=True add_file_common_args=True
) )
changed = False changed = False
pathmd5 = None pathmd5 = None
destmd5 = None destmd5 = None
src = os.path.expanduser(module.params['src']) src = os.path.expanduser(module.params['src'])
dest = os.path.expanduser(module.params['dest']) dest = os.path.expanduser(module.params['dest'])
backup = module.params['backup'] backup = module.params['backup']
delimiter = module.params['delimiter'] delimiter = module.params['delimiter']
if not os.path.exists(src): if not os.path.exists(src):
module.fail_json(msg="Source (%s) does not exist" % src) module.fail_json(msg="Source (%s) does not exist" % src)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment