propellor spin

This commit is contained in:
Joey Hess 2014-07-18 00:20:09 -04:00
parent 863cdf470b
commit 5590c1c75a
Failed to extract signature
2 changed files with 22 additions and 4 deletions

View File

@ -63,7 +63,6 @@ hosts = -- (o) `
[ "Main git-annex build box." ]
& ipv4 "138.38.108.179"
& Hostname.sane
& Apt.unattendedUpgrades
& Postfix.satellite
& Docker.configured
@ -85,7 +84,6 @@ hosts = -- (o) `
& Apt.installed ["linux-image-amd64"]
& Linode.chainPVGrub 5
& Hostname.sane
& Apt.unattendedUpgrades
& Apt.installed ["systemd"]
& Ssh.hostKeys (Context "kitenet.net")
@ -110,7 +108,6 @@ hosts = -- (o) `
& ipv4 "107.170.31.195"
& DigitalOcean.distroKernel
& Hostname.sane
& Ssh.hostKeys (Context "diatom.kitenet.net")
& Apt.unattendedUpgrades
& Apt.serviceInstalledRunning "ntp"
@ -174,7 +171,6 @@ hosts = -- (o) `
& ipv4 "193.234.225.114"
& Grub.chainPVGrub "hd0,0" "xen/xvda1" 30
& Hostname.sane
& Postfix.satellite
& Apt.unattendedUpgrades
& Ssh.hostKeys ctx
@ -286,6 +282,8 @@ type Motd = [String]
standardSystem :: HostName -> DebianSuite -> Architecture -> Motd -> Host
standardSystem hn suite arch motd = host hn
& os (System (Debian suite) arch)
& Hostname.sane
& Hostname.searchDomain
& File.hasContent "/etc/motd" ("":motd++[""])
& Apt.stdSourcesList `onChange` Apt.upgrade
& Apt.cacheCleaned

View File

@ -3,6 +3,8 @@ module Propellor.Property.Hostname where
import Propellor
import qualified Propellor.Property.File as File
import Data.List
-- | Ensures that the hostname is set using best practices.
--
-- Configures /etc/hostname and the current hostname.
@ -37,3 +39,21 @@ setTo hn = combineProperties desc go
addhostsline ip names ls =
(ip ++ "\t" ++ (unwords names)) : filter (not . hasip ip) ls
hasip ip l = headMaybe (words l) == Just ip
-- | Makes /etc/resolv.conf contain search and domain lines for
-- the domain that the hostname is in.
searchDomain :: Property
searchDomain = property desc (ensureProperty . go =<< asks hostName)
where
desc = "resolv.conf search and domain configured"
go hn =
let (_basehost, domain) = separate (== '.') hn
in File.fileProperty desc (use domain) "/etc/resolv.conf"
use domain ls = filter wanted $ nub (ls ++ cfgs)
where
cfgs = ["domain " ++ domain, "search " ++ domain]
wanted l
| l `elem` cfgs = True
| "domain " `isPrefixOf` l = False
| "search " `isPrefixOf` l = False
| otherwise = True