From 68d7ddb3078bbb0ad7cdc634a0edafa3f99cd254 Mon Sep 17 00:00:00 2001 From: Veli-Matti Lintu Date: Wed, 13 Jun 2018 13:07:14 +0300 Subject: [PATCH] Commit 701678c9 changes print statements to print functions with end=' '. As the printed strings contain newlines, this causes a space to be written as the first character of the following line causing them to be indented. An example config that is broken. Here disabling modules indents all the other lines of cloud.cfg except the first one causing the username name setting to fail as it expects indenting to be certain number of spaces. plugins: cloud_init: metadata_sources: Ec2 username: admin disable_modules: - locale - mounts This commit removes the spaces by specifying end=''. --- bootstrapvz/common/tools.py | 2 +- bootstrapvz/plugins/cloud_init/tasks.py | 4 ++-- bootstrapvz/plugins/ntp/tasks.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bootstrapvz/common/tools.py b/bootstrapvz/common/tools.py index 9fdceb8..ed895a4 100644 --- a/bootstrapvz/common/tools.py +++ b/bootstrapvz/common/tools.py @@ -83,7 +83,7 @@ def inline_replace(file_path, pattern, subst): for line in fileinput.input(files=file_path, inplace=True): (replacement, count) = re.subn(pattern, subst, line) replacement_count += count - print(replacement, end=' ') + print(replacement, end='') return replacement_count diff --git a/bootstrapvz/plugins/cloud_init/tasks.py b/bootstrapvz/plugins/cloud_init/tasks.py index 9504cf9..ac4bf89 100644 --- a/bootstrapvz/plugins/cloud_init/tasks.py +++ b/bootstrapvz/plugins/cloud_init/tasks.py @@ -100,7 +100,7 @@ class DisableModules(Task): import fileinput for line in fileinput.input(files=cloud_cfg, inplace=True): if not regex.match(line): - print(line, end=' ') + print(line, end='') class EnableModules(Task): @@ -124,7 +124,7 @@ class EnableModules(Task): count = count + 1 if int(entry['position']) == int(count): print(" - %s" % entry['module']) - print(line, end=' ') + print(line, end='') class SetCloudInitMountOptions(Task): diff --git a/bootstrapvz/plugins/ntp/tasks.py b/bootstrapvz/plugins/ntp/tasks.py index 5e8e674..9e6c7f9 100644 --- a/bootstrapvz/plugins/ntp/tasks.py +++ b/bootstrapvz/plugins/ntp/tasks.py @@ -31,4 +31,4 @@ class SetNtpServers(Task): while servers: print('server {server_address} iburst'.format(server_address=servers.pop(0))) else: - print(line, end=' ') + print(line, end='')