From 3853d2a9a6fb8a6cc85f5d8525eb3190408d8dec Mon Sep 17 00:00:00 2001 From: Toshio Kuratomi Date: Mon, 29 Feb 2016 00:38:10 -0800 Subject: [PATCH] Change parameter to type=path Read as binary for python3 preparedness --- network/basics/slurp.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/network/basics/slurp.py b/network/basics/slurp.py index f96434f5fd3..d017e849e64 100644 --- a/network/basics/slurp.py +++ b/network/basics/slurp.py @@ -55,23 +55,24 @@ import base64 def main(): module = AnsibleModule( argument_spec = dict( - src = dict(required=True, aliases=['path']), + src = dict(required=True, aliases=['path'], type='path'), ), supports_check_mode=True ) - source = os.path.expanduser(module.params['src']) + source = module.params['src'] if not os.path.exists(source): module.fail_json(msg="file not found: %s" % source) if not os.access(source, os.R_OK): module.fail_json(msg="file is not readable: %s" % source) - data = base64.b64encode(file(source).read()) + data = base64.b64encode(open(source, 'rb').read()) module.exit_json(content=data, source=source, encoding='base64') # import module snippets from ansible.module_utils.basic import * -main() +if __name__ == '__main__': + main()