From 14e3febb2cc0c79b66ef913f6a151aed2db8440a Mon Sep 17 00:00:00 2001 From: Jose Rodriguez Date: Thu, 23 Aug 2018 20:33:00 +0200 Subject: [PATCH] Prevent utf-8 codec error in py3 (#44228) Cannot upload templates in Python 3.x. Gives utf-8 codec error. Fixes this by opening the template file in binary mode. --- lib/ansible/modules/cloud/misc/proxmox_template.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ansible/modules/cloud/misc/proxmox_template.py b/lib/ansible/modules/cloud/misc/proxmox_template.py index a82a453ca1..d9c002028d 100644 --- a/lib/ansible/modules/cloud/misc/proxmox_template.py +++ b/lib/ansible/modules/cloud/misc/proxmox_template.py @@ -136,7 +136,7 @@ def get_template(proxmox, node, storage, content_type, template): def upload_template(module, proxmox, api_host, node, storage, content_type, realpath, timeout): - taskid = proxmox.nodes(node).storage(storage).upload.post(content=content_type, filename=open(realpath)) + taskid = proxmox.nodes(node).storage(storage).upload.post(content=content_type, filename=open(realpath, 'rb')) while timeout: task_status = proxmox.nodes(api_host.split('.')[0]).tasks(taskid).status.get() if task_status['status'] == 'stopped' and task_status['exitstatus'] == 'OK':