Change parameter to type=path
Read as binary for python3 preparedness
This commit is contained in:
parent
2920658776
commit
3853d2a9a6
1 changed files with 5 additions and 4 deletions
|
@ -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()
|
||||
|
||||
|
|
Loading…
Reference in a new issue