Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

trouble with ubuntu (osfamily:debian) to setup entry 127.0.1.1 <fqdn> #73

Closed
janreiche opened this issue Aug 23, 2018 · 2 comments
Closed

Comments

@janreiche
Copy link

In Ubuntu (and osfamily:debian) it seems to be necessary to add a configuration like this:

127.0.0.1       localhost.localdomain   localhost
127.0.1.1       <fqdn>   <short host name>

see https://wiki.ubuntuusers.de/hosts/ or

-- $ man hostname --
The  recommended  method  of setting the FQDN is to make the hostname be an alias for the fully qualified name using /etc/hosts, DNS, or
       NIS. For example, if the hostname was "ursula", one might have a line in /etc/hosts which reads

              127.0.1.1    ursula.example.com ursula
--

because otherwise I faced an Error with duplicated entries for "localhost.localdomain":
The problem is, that ubuntu reads the first entry in /etc/hosts to determine fqdn, which is the first entry created by this modul "localhost.localdomain"
Enabling use_fqdn now leads to an error, because this host entry is already configured (race condition). The error is ok, because a fix is necessary.
Also I don't want to use the public ip "$::address" as fqdn (use_fqdn => false), because I want it to be configured for "127.0.1.1" and it could not exist as duplicate for the fqdn entry.
Moreover if the net device gets detached somehow or by purpose, the host could not determine its name anymore, which leads to timeouts for commands, which try to resolve the hostname, like sudo and so on.

My configuration therefore is:
enable_fqdn_entry => false |  
use_fqdn          => false |
host_entries      => 
<%= @host.facts['networking::hostname'] + "." + @host.facts['networking::domain'] -%>:
  ip: '127.0.1.1'
  host_aliases:
  - <%= @host.facts['networking::hostname'] -%>

I suggest a code change at the end of the manifest (line 146-150) to solve this:

if $host_entries != undef {
  if $fqdn_entry_enabled {
    # ensure host entry for fqdn is not duplicated
    $host_entries_real = delete($host_entries,$::fqdn)
	# create resources
    validate_hash($host_entries_real)
    create_resources(host,$host_entries_real)
  } else {
    # create resources
    validate_hash($host_entries)
    create_resources(host,$host_entries)
  }
}

This issue seems to be similar to
issues/40
but it differs because there it is suggested that the exported resource becomes a normal host entry.

threepistons added a commit to threepistons/puppet-module-hosts that referenced this issue Oct 17, 2018
Mobile workstations need to use 127.0.1.1 and not $::ipaddress.  Defaulting to $::ipaddress not to break existing behaviour
@threepistons
Copy link

blues-man#1 fixes on Ubuntu 18.04.

blues-man added a commit to blues-man/puppet-module-hosts that referenced this issue Oct 17, 2018
@ghoneycutt
Copy link
Owner

Closing as we have simplified the module with v3.0.0

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants