fix a bug preventing custom credential templates from including unicode

see: https://github.com/ansible/tower/issues/1266
This commit is contained in:
Ryan Petrello
2018-04-09 17:03:22 -04:00
parent dd5a34ce3b
commit b1028a2e0a
2 changed files with 31 additions and 1 deletions

View File

@@ -632,7 +632,7 @@ class CredentialType(CommonModelNameNotUnique):
data = Template(file_tmpl).render(**namespace)
_, path = tempfile.mkstemp(dir=private_data_dir)
with open(path, 'w') as f:
f.write(data)
f.write(data.encode('utf-8'))
os.chmod(path, stat.S_IRUSR | stat.S_IWUSR)
# determine if filename indicates single file or many