Hostname.sane now cleans up the 127.0.0.1 localhost line in /etc/hosts, to avoid eg, apache complaining that "Could not reliably determine the server's fully qualified domain name".
This commit is contained in:
parent
8a909951cb
commit
26f989b5ab
|
@ -4,6 +4,9 @@ propellor (0.7.1) UNRELEASED; urgency=medium
|
||||||
* Add --list-fields to list a host's currently set privdata fields.
|
* Add --list-fields to list a host's currently set privdata fields.
|
||||||
* Fix randomHostKeys property to run openssh-server's postinst in a
|
* Fix randomHostKeys property to run openssh-server's postinst in a
|
||||||
non-failing way.
|
non-failing way.
|
||||||
|
* Hostname.sane now cleans up the 127.0.0.1 localhost line in /etc/hosts,
|
||||||
|
to avoid eg, apache complaining that "Could not reliably determine the
|
||||||
|
server's fully qualified domain name".
|
||||||
|
|
||||||
-- Joey Hess <joeyh@debian.org> Thu, 19 Jun 2014 14:27:21 -0400
|
-- Joey Hess <joeyh@debian.org> Thu, 19 Jun 2014 14:27:21 -0400
|
||||||
|
|
||||||
|
|
|
@ -3,11 +3,16 @@ module Propellor.Property.Hostname where
|
||||||
import Propellor
|
import Propellor
|
||||||
import qualified Propellor.Property.File as File
|
import qualified Propellor.Property.File as File
|
||||||
|
|
||||||
-- | Ensures that the hostname is set to the HostInfo value.
|
-- | Ensures that the hostname is set using best practices.
|
||||||
|
--
|
||||||
-- Configures /etc/hostname and the current hostname.
|
-- Configures /etc/hostname and the current hostname.
|
||||||
--
|
--
|
||||||
-- A FQDN also configures /etc/hosts, with an entry for 127.0.1.1, which is
|
-- /etc/hosts is also configured, with an entry for 127.0.1.1, which is
|
||||||
-- standard at least on Debian to set the FDQN (127.0.0.1 is localhost).
|
-- standard at least on Debian to set the FDQN.
|
||||||
|
--
|
||||||
|
-- Also, the /etc/hosts 127.0.0.1 line is set to localhost. Putting any
|
||||||
|
-- other hostnames there is not best practices and can lead to annoying
|
||||||
|
-- messages from eg, apache.
|
||||||
sane :: Property
|
sane :: Property
|
||||||
sane = property ("sane hostname") (ensureProperty . setTo =<< asks hostName)
|
sane = property ("sane hostname") (ensureProperty . setTo =<< asks hostName)
|
||||||
|
|
||||||
|
@ -21,13 +26,14 @@ setTo hn = combineProperties desc go
|
||||||
[ Just $ "/etc/hostname" `File.hasContent` [basehost]
|
[ Just $ "/etc/hostname" `File.hasContent` [basehost]
|
||||||
, if null domain
|
, if null domain
|
||||||
then Nothing
|
then Nothing
|
||||||
else Just $ File.fileProperty desc
|
else Just $ hostsline "127.0.1.1" [hn, basehost]
|
||||||
addhostline "/etc/hosts"
|
, Just $ hostsline "127.0.0.1" ["localhost"]
|
||||||
, Just $ trivial $ cmdProperty "hostname" [basehost]
|
, Just $ trivial $ cmdProperty "hostname" [basehost]
|
||||||
]
|
]
|
||||||
|
|
||||||
hostip = "127.0.1.1"
|
hostsline ip names = File.fileProperty desc
|
||||||
hostline = hostip ++ "\t" ++ hn ++ " " ++ basehost
|
(addhostsline ip names)
|
||||||
|
"/etc/hosts"
|
||||||
addhostline ls = hostline : filter (not . hashostip) ls
|
addhostsline ip names ls =
|
||||||
hashostip l = headMaybe (words l) == Just hostip
|
(ip ++ "\t" ++ (unwords names)) : filter (not . hasip ip) ls
|
||||||
|
hasip ip l = headMaybe (words l) == Just ip
|
||||||
|
|
Loading…
Reference in New Issue