Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions cloudinit/distros/opensuse.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,9 @@ def _read_hostname(self, filename, default=None):
return default
return hostname

def _get_localhost_ip(self):
return "127.0.1.1"

def _read_hostname_conf(self, filename):
conf = HostnameConf(util.load_file(filename))
conf.parse()
Expand Down
2 changes: 1 addition & 1 deletion templates/hosts.suse.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ you need to add the following to config:
# /etc/cloud/cloud.cfg or cloud-config from user-data
#
# The following lines are desirable for IPv4 capable hosts
127.0.0.1 {{fqdn}} {{hostname}}
127.0.1.1 {{fqdn}} {{hostname}}
127.0.0.1 localhost.localdomain localhost
127.0.0.1 localhost4.localdomain4 localhost4

Expand Down
8 changes: 4 additions & 4 deletions tests/unittests/test_handler/test_handler_etc_hosts.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ def test_write_etc_hosts_suse_localhost(self):
self.patchUtils(self.tmp)
cc_update_etc_hosts.handle('test', cfg, cc, LOG, [])
contents = util.load_file('%s/etc/hosts' % self.tmp)
if '127.0.0.1\tcloud-init.test.us\tcloud-init' not in contents:
self.assertIsNone('No entry for 127.0.0.1 in etc/hosts')
if '127.0.1.1\tcloud-init.test.us\tcloud-init' not in contents:
self.assertIsNone('No entry for 127.0.1.1 in etc/hosts')
if '192.168.1.1\tblah.blah.us\tblah' not in contents:
self.assertIsNone('Default etc/hosts content modified')

Expand All @@ -64,7 +64,7 @@ def test_write_etc_hosts_suse_template(self):
self.patchUtils(self.tmp)
cc_update_etc_hosts.handle('test', cfg, cc, LOG, [])
contents = util.load_file('%s/etc/hosts' % self.tmp)
if '127.0.0.1 cloud-init.test.us cloud-init' not in contents:
self.assertIsNone('No entry for 127.0.0.1 in etc/hosts')
if '127.0.1.1 cloud-init.test.us cloud-init' not in contents:
self.assertIsNone('No entry for 127.0.1.1 in etc/hosts')
if '::1 cloud-init.test.us cloud-init' not in contents:
self.assertIsNone('No entry for 127.0.0.1 in etc/hosts')