summaryrefslogtreecommitdiff
path: root/cloudinit/config/cc_rsyslog.py
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2015-07-28 10:34:31 -0400
committerScott Moser <smoser@ubuntu.com>2015-07-28 10:34:31 -0400
commitc6e7fb1752a93ed534080adf0588e4c7cdd99071 (patch)
tree48c3def00df21141210f6425061c1e5e9f899218 /cloudinit/config/cc_rsyslog.py
parentf61a62434b36ab873b2b82a5ba69eda826755bfc (diff)
downloadvyos-cloud-init-c6e7fb1752a93ed534080adf0588e4c7cdd99071.tar.gz
vyos-cloud-init-c6e7fb1752a93ed534080adf0588e4c7cdd99071.zip
add trailing newline only if necessary
Diffstat (limited to 'cloudinit/config/cc_rsyslog.py')
-rw-r--r--cloudinit/config/cc_rsyslog.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/cloudinit/config/cc_rsyslog.py b/cloudinit/config/cc_rsyslog.py
index 915ab420..2bb00728 100644
--- a/cloudinit/config/cc_rsyslog.py
+++ b/cloudinit/config/cc_rsyslog.py
@@ -188,8 +188,7 @@ def apply_rsyslog_changes(configs, def_fname, cfg_dir):
LOG.warn("Entry %s has an empty filename", cur_pos + 1)
continue
- if not filename.startswith("/"):
- filename = os.path.join(cfg_dir, filename)
+ filename = os.path.join(cfg_dir, filename)
# Truncate filename first time you see it
omode = "ab"
@@ -198,8 +197,10 @@ def apply_rsyslog_changes(configs, def_fname, cfg_dir):
files.append(filename)
try:
- contents = "%s\n" % (content)
- util.write_file(filename, contents, omode=omode)
+ endl = ""
+ if not content.endswith("\n"):
+ endl = "\n"
+ util.write_file(filename, content + endl, omode=omode)
except Exception:
util.logexc(LOG, "Failed to write to %s", filename)