diff options
author | Joshua Harlow <harlowja@yahoo-inc.com> | 2015-04-21 11:52:00 -0700 |
---|---|---|
committer | Joshua Harlow <harlowja@yahoo-inc.com> | 2015-04-21 11:52:00 -0700 |
commit | b7ce7a29941497080695e35a9f2dc772664c73b9 (patch) | |
tree | 9b59e85c6eca27f2acad25e8b37b43fcd4b3064c | |
parent | ab04d7a3e0d210805c9db99bf43eb47808809758 (diff) | |
parent | 96820355ea20fe655a7ebbb68ffb309bf234ab37 (diff) | |
download | vyos-cloud-init-b7ce7a29941497080695e35a9f2dc772664c73b9.tar.gz vyos-cloud-init-b7ce7a29941497080695e35a9f2dc772664c73b9.zip |
Don't overwrite the hostname if the user has changed it after we set it
-rw-r--r-- | cloudinit/distros/__init__.py | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/cloudinit/distros/__init__.py b/cloudinit/distros/__init__.py index b297c78b..05721922 100644 --- a/cloudinit/distros/__init__.py +++ b/cloudinit/distros/__init__.py @@ -208,6 +208,15 @@ class Distro(object): and sys_hostname != hostname): update_files.append(sys_fn) + # If something else has changed the hostname after we set it + # initially, we should not overwrite those changes (we should + # only be setting the hostname once per instance) + if (sys_hostname and prev_hostname and + sys_hostname != prev_hostname): + LOG.info("%s differs from %s, assuming user maintained hostname.", + prev_hostname_fn, sys_fn) + return + # Remove duplicates (incase the previous config filename) # is the same as the system config filename, don't bother # doing it twice @@ -222,11 +231,6 @@ class Distro(object): util.logexc(LOG, "Failed to write hostname %s to %s", hostname, fn) - if (sys_hostname and prev_hostname and - sys_hostname != prev_hostname): - LOG.debug("%s differs from %s, assuming user maintained hostname.", - prev_hostname_fn, sys_fn) - # If the system hostname file name was provided set the # non-fqdn as the transient hostname. if sys_fn in update_files: |