Merge lp:~zulcss/vmbuilder/vmbuilder-hostname into lp:vmbuilder/trunk

Proposed by Chuck Short
Status: Needs review
Proposed branch: lp:~zulcss/vmbuilder/vmbuilder-hostname
Merge into: lp:vmbuilder/trunk
Diff against target: None lines
To merge this branch: bzr merge lp:~zulcss/vmbuilder/vmbuilder-hostname
Reviewer Review Type Date Requested Status
Soren Hansen Pending
Review via email: mp+7462@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Chuck Short (zulcss) wrote :

Let DHCP manage the hostname if its not specified.

314. By Chuck Short

Better detection for DHCP

Revision history for this message
Soren Hansen (soren) wrote :

On Mon, Jun 15, 2009 at 06:15:15PM -0000, Chuck Short wrote:
> === modified file 'VMBuilder/plugins/ubuntu/dapper.py'
> --- VMBuilder/plugins/ubuntu/dapper.py 2009-06-10 13:40:41 +0000
> +++ VMBuilder/plugins/ubuntu/dapper.py 2009-06-15 18:11:35 +0000
> @@ -164,7 +164,8 @@
> return 'linux-image-%s' % (self.vm.flavour or self.default_flavour[self.vm.arch],)
>
> def config_network(self):
> - self.vm.install_file('/etc/hostname', self.vm.hostname)
> + if self.vm.hostname:
> + self.vm.install_file('/etc/hostname', self.vm.hostname)
> self.install_from_template('/etc/hosts', 'etc_hosts', { 'hostname' : self.vm.hostname, 'domain' : self.vm.domain })
> self.install_from_template('/etc/network/interfaces', 'interfaces')
>

Going throug the regular installer, don't we always end up with a
/etc/hostname ? The installer, AFAIK, invariably asks for the hostname
at least. I'd be surprised if it didn't put it in /etc/hostname, but
ICBW.

--
Soren Hansen |
Lead Virtualisation Engineer | Ubuntu Server Team
Canonical Ltd. | http://www.ubuntu.com/

Revision history for this message
Eric Hammond (esh) wrote :

Soren Hansen wrote:
> Going throug the regular installer, don't we always end up with a
> /etc/hostname ? The installer, AFAIK, invariably asks for the hostname
> at least. I'd be surprised if it didn't put it in /etc/hostname, but
> ICBW.

I'm not sure about the answer to the direct question, but Ubuntu on EC2
behaves better if /etc/hostname is omitted and it lets Amazon's DHCP
pick the hostname.

If /etc/hostname is set on an EC2 instance and that instance gets
rebundled into a new image, then all instances of that new image start
with the same old hostname instead of letting DHCP set it correctly again.

If the EC2 user decides to create /etc/hostname, that's their
prerogative, but the default and public images should not.

--
Eric Hammond
<email address hidden>

Unmerged revisions

314. By Chuck Short

Better detection for DHCP

313. By Chuck Short

Let DHCP set the hostname if its not specified

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'VMBuilder/plugins/ubuntu/dapper.py'
2--- VMBuilder/plugins/ubuntu/dapper.py 2009-06-10 13:40:41 +0000
3+++ VMBuilder/plugins/ubuntu/dapper.py 2009-06-15 18:11:35 +0000
4@@ -164,7 +164,8 @@
5 return 'linux-image-%s' % (self.vm.flavour or self.default_flavour[self.vm.arch],)
6
7 def config_network(self):
8- self.vm.install_file('/etc/hostname', self.vm.hostname)
9+ if self.vm.hostname:
10+ self.vm.install_file('/etc/hostname', self.vm.hostname)
11 self.install_from_template('/etc/hosts', 'etc_hosts', { 'hostname' : self.vm.hostname, 'domain' : self.vm.domain })
12 self.install_from_template('/etc/network/interfaces', 'interfaces')
13
14
15=== modified file 'VMBuilder/plugins/ubuntu/templates/etc_hosts.tmpl'
16--- VMBuilder/plugins/ubuntu/templates/etc_hosts.tmpl 2008-09-18 09:11:09 +0000
17+++ VMBuilder/plugins/ubuntu/templates/etc_hosts.tmpl 2009-06-15 18:11:35 +0000
18@@ -1,5 +1,7 @@
19 127.0.0.1 localhost
20+#if $hostname
21 127.0.1.1 $hostname.$domain $hostname
22+#endif
23
24 # The following lines are desirable for IPv6 capable hosts
25 ::1 ip6-localhost ip6-loopback

Subscribers

People subscribed via source and target branches