summaryrefslogtreecommitdiff
path: root/cloudinit
diff options
context:
space:
mode:
authorJoshua Harlow <harlowja@yahoo-inc.com>2012-06-18 17:25:10 -0700
committerJoshua Harlow <harlowja@yahoo-inc.com>2012-06-18 17:25:10 -0700
commit24b818fd7c26ccc4c31191c1ae274a5fff506038 (patch)
treeca27d2bd7bada5d001f6ebe6ba7789944dfadc87 /cloudinit
parent1d6c6b6a97ca06f0044e7a3987d76519b4feee9e (diff)
downloadvyos-cloud-init-24b818fd7c26ccc4c31191c1ae274a5fff506038.tar.gz
vyos-cloud-init-24b818fd7c26ccc4c31191c1ae274a5fff506038.zip
Add created by or added by cloud-init lines when we modify or create files.
Diffstat (limited to 'cloudinit')
-rw-r--r--cloudinit/distros/rhel.py3
-rw-r--r--cloudinit/distros/ubuntu.py5
2 files changed, 7 insertions, 1 deletions
diff --git a/cloudinit/distros/rhel.py b/cloudinit/distros/rhel.py
index 85283b23..e0ca5909 100644
--- a/cloudinit/distros/rhel.py
+++ b/cloudinit/distros/rhel.py
@@ -70,6 +70,7 @@ class Distro(distros.Distro):
mac_addr = info.get('hwaddress')
if mac_addr:
lines.append("MACADDR=%s" % (mac_addr))
+ lines.insert(0, '# Created by cloud-init')
contents = "\n".join(lines)
net_fn = NETWORK_FN_TPL % (dev)
util.write_file(net_fn, contents, 0644)
@@ -100,6 +101,7 @@ class Distro(distros.Distro):
new_contents.append("=".join([cmd, args]))
# Guess not found, append it
if not adjusted:
+ new_contents.append("# Added by cloud-init")
new_contents.append("HOSTNAME=%s" % (hostname))
contents = "\n".join(new_contents)
util.write_file(out_fn, contents, 0644)
@@ -189,6 +191,7 @@ class Distro(distros.Distro):
new_contents.append("=".join([cmd, args]))
# Guess not found, append it
if not zone_added:
+ new_contents.append("# Added by cloud-init")
new_contents.append('ZONE="%s"' % (tz))
tz_contents = "\n".join(new_contents)
util.write_file("/etc/sysconfig/clock", tz_contents)
diff --git a/cloudinit/distros/ubuntu.py b/cloudinit/distros/ubuntu.py
index c0345c1d..24724d83 100644
--- a/cloudinit/distros/ubuntu.py
+++ b/cloudinit/distros/ubuntu.py
@@ -54,7 +54,10 @@ class Distro(distros.Distro):
util.subp(['hostname', hostname])
def _write_hostname(self, hostname, out_fn):
- contents = "%s\n" % (hostname)
+ lines = []
+ lines.append("# Created by cloud-init")
+ lines.append(str(hostname))
+ contents = "\n".join(lines)
util.write_file(out_fn, contents, 0644)
def update_hostname(self, hostname, prev_file):