call to_text on full config file
fixes issue #30571
(cherry picked from commit 0a114436fc
)
This commit is contained in:
parent
f88c8e1df9
commit
d9a87fff5f
1 changed files with 4 additions and 3 deletions
|
@ -438,6 +438,7 @@ else:
|
|||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.parsing.convert_bool import BOOLEANS_FALSE, BOOLEANS_TRUE
|
||||
from ansible.module_utils.six.moves import xrange
|
||||
from ansible.module_utils._text import to_text, to_bytes
|
||||
|
||||
|
||||
# LXC_COMPRESSION_MAP is a map of available compression types when creating
|
||||
|
@ -572,7 +573,7 @@ def create_script(command):
|
|||
(fd, script_file) = tempfile.mkstemp(prefix='lxc-attach-script')
|
||||
f = os.fdopen(fd, 'wb')
|
||||
try:
|
||||
f.write(ATTACH_TEMPLATE % {'container_command': command})
|
||||
f.write(to_bytes(ATTACH_TEMPLATE % {'container_command': command}, errors='surrogate_or_strict'))
|
||||
f.flush()
|
||||
finally:
|
||||
f.close()
|
||||
|
@ -724,7 +725,7 @@ class LxcContainerManagement(object):
|
|||
|
||||
container_config_file = self.container.config_file_name
|
||||
with open(container_config_file, 'rb') as f:
|
||||
container_config = f.readlines()
|
||||
container_config = to_text(f.read(), errors='surrogate_or_strict').splitlines()
|
||||
|
||||
# Note used ast literal_eval because AnsibleModule does not provide for
|
||||
# adequate dictionary parsing.
|
||||
|
@ -765,7 +766,7 @@ class LxcContainerManagement(object):
|
|||
self.container.stop()
|
||||
|
||||
with open(container_config_file, 'wb') as f:
|
||||
f.writelines(container_config)
|
||||
f.writelines([to_bytes(line, errors='surrogate_or_strict') for line in container_config])
|
||||
|
||||
self.state_change = True
|
||||
if container_state == 'running':
|
||||
|
|
Loading…
Reference in a new issue