Bug 1251499
Summary: | virt-builder --hostname should replace FQDN in /etc/hosts on Ubuntu | ||
---|---|---|---|
Product: | [Community] Virtualization Tools | Reporter: | Dominic Cleal <dcleal> |
Component: | libguestfs | Assignee: | Pino Toscano <ptoscano> |
Status: | CLOSED DUPLICATE | QA Contact: | |
Severity: | unspecified | Docs Contact: | |
Priority: | unspecified | ||
Version: | unspecified | CC: | ptoscano, rbalakri, rjones |
Target Milestone: | --- | ||
Target Release: | --- | ||
Hardware: | Unspecified | ||
OS: | Unspecified | ||
Whiteboard: | |||
Fixed In Version: | Doc Type: | Bug Fix | |
Doc Text: | Story Points: | --- | |
Clone Of: | Environment: | ||
Last Closed: | 2016-09-22 16:00:22 UTC | Type: | Bug |
Regression: | --- | Mount Type: | --- |
Documentation: | --- | CRM: | |
Verified Versions: | Category: | --- | |
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
Cloudforms Team: | --- | Target Upstream Version: | |
Embargoed: |
Description
Dominic Cleal
2015-08-07 14:00:13 UTC
We already replace the hostname in /etc/hosts; without that, the hosts line would be: 127.0.1.1 unassigned-hostname.unassigned-domain unassigned-hostname but /etc/hostname contains only "unassigned-hostname", so we replace that only. I guess /etc/hostname should contain only the hostname and not FQDN, which would rather go in /etc/hosts. But then, we should somehow assume that "unassigned-hostname.unassigned-domain" is a template, which is something I wanted to avoid if possible... but then, there seems to be no other place where FQDN is set. (In reply to Pino Toscano from comment #1) > We already replace the hostname in /etc/hosts; without that, the hosts line > would be: > > 127.0.1.1 unassigned-hostname.unassigned-domain unassigned-hostname > > but /etc/hostname contains only "unassigned-hostname", so we replace that > only. > I guess /etc/hostname should contain only the hostname and not FQDN, which > would rather go in /etc/hosts. Indeed, it's more typical under Debian/Ubuntu to take the hostname portion only and put it in /etc/hostname (so `hostname` returns "test", while on a RH OS it would typically be the FQDN). > But then, we should somehow assume that > "unassigned-hostname.unassigned-domain" is a template, which is something I > wanted to avoid if possible... but then, there seems to be no other place > where FQDN is set. That's right, it would be determined from a name lookup (DNS or /etc/hosts by default). The ideal behaviour would be to split the --hostname argument into the short name and FQDN, put the short name into /etc/hostname, perform the existing /etc/hosts replacement with the short name and then replace any "oldhostname.*" nodes in /etc/hosts with the FQDN. (In reply to Dominic Cleal from comment #2) > (In reply to Pino Toscano from comment #1) > > We already replace the hostname in /etc/hosts; without that, the hosts line > > would be: > > > > 127.0.1.1 unassigned-hostname.unassigned-domain unassigned-hostname > > > > but /etc/hostname contains only "unassigned-hostname", so we replace that > > only. > > I guess /etc/hostname should contain only the hostname and not FQDN, which > > would rather go in /etc/hosts. > > Indeed, it's more typical under Debian/Ubuntu to take the hostname portion > only and put it in /etc/hostname (so `hostname` returns "test", while on a > RH OS it would typically be the FQDN). Right. This also reminds me we are not changing the hostname at all in /etc/hosts on Fedora/RHEL systems. > > But then, we should somehow assume that > > "unassigned-hostname.unassigned-domain" is a template, which is something I > > wanted to avoid if possible... but then, there seems to be no other place > > where FQDN is set. > > That's right, it would be determined from a name lookup (DNS or /etc/hosts > by default). > > The ideal behaviour would be to split the --hostname argument into the short > name and FQDN, put the short name into /etc/hostname, perform the existing > /etc/hosts replacement with the short name and then replace any > "oldhostname.*" nodes in /etc/hosts with the FQDN. The problem I see is that "oldhostname.*" may match also other nodes (not common case, but still potentially there): on Fedora/RHEL systems it is not an issue, since knowing the FQDN allows us to replace it fully, but on Debian/Ubuntu systems this is problematic. (In reply to Pino Toscano from comment #3) > (In reply to Dominic Cleal from comment #2) > > (In reply to Pino Toscano from comment #1) > > > We already replace the hostname in /etc/hosts; without that, the hosts line > > > would be: > > > > > > 127.0.1.1 unassigned-hostname.unassigned-domain unassigned-hostname > > > > > > but /etc/hostname contains only "unassigned-hostname", so we replace that > > > only. > > > I guess /etc/hostname should contain only the hostname and not FQDN, which > > > would rather go in /etc/hosts. > > > > Indeed, it's more typical under Debian/Ubuntu to take the hostname portion > > only and put it in /etc/hostname (so `hostname` returns "test", while on a > > RH OS it would typically be the FQDN). > > Right. > This also reminds me we are not changing the hostname at all in /etc/hosts > on Fedora/RHEL systems. Indeed, it's just more common with Debian/Ubuntu due to the FQDN being set up as a localhost alias by the installer. > > > But then, we should somehow assume that > > > "unassigned-hostname.unassigned-domain" is a template, which is something I > > > wanted to avoid if possible... but then, there seems to be no other place > > > where FQDN is set. > > > > That's right, it would be determined from a name lookup (DNS or /etc/hosts > > by default). > > > > The ideal behaviour would be to split the --hostname argument into the short > > name and FQDN, put the short name into /etc/hostname, perform the existing > > /etc/hosts replacement with the short name and then replace any > > "oldhostname.*" nodes in /etc/hosts with the FQDN. > > The problem I see is that "oldhostname.*" may match also other nodes (not > common case, but still potentially there): on Fedora/RHEL systems it is not > an issue, since knowing the FQDN allows us to replace it fully, but on > Debian/Ubuntu systems this is problematic. True, and I suppose I was skipping over this concern as I was thinking only of virt-builder where the inputs are more constrained. With virt-customize etc it'd be a risk. You could be more specific in only changing an /etc/hosts entry if you've already replaced the short hostname on the same line (given that you're dealing with a canonical name and an alias, rather than two separate addresses). The workaround is this (untested): --edit '/etc/hosts: s/unassigned-hostname.unassigned-domain/newhostname.fqdn/' This was later fixed as bug 1372269. *** This bug has been marked as a duplicate of bug 1372269 *** |