Push the expanduser call on the source down to slurp rather than fetch

Also moves the calculation of the destination file name until after
the slurp of the file contents, since the source as returned by slurp
may now be different, so we want to use that expanded path locally.

Fixes #8942
This commit is contained in:
James Cammarata
2014-09-23 15:19:50 -05:00
parent 889dfc4374
commit e47f6137e5
2 changed files with 24 additions and 17 deletions

View File

@@ -57,7 +57,7 @@ def main():
),
supports_check_mode=True
)
source = module.params['src']
source = os.path.expanduser(module.params['src'])
if not os.path.exists(source):
module.fail_json(msg="file not found: %s" % source)
@@ -66,7 +66,7 @@ def main():
data = base64.b64encode(file(source).read())
module.exit_json(content=data, encoding='base64')
module.exit_json(content=data, source=source, encoding='base64')
# import module snippets
from ansible.module_utils.basic import *