summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJoey Hess2015-01-04 19:32:15 -0400
committerJoey Hess2015-01-04 19:32:15 -0400
commit570bcde9eddf8f4c6639a8c27dbe869f3bc31f4a (patch)
tree5c39cb43ad70c7abd3e8f63966c64d6bd793656c /src
parent8ac335a085191345f3b5c7cde416830909ae244a (diff)
propellor spin
Diffstat (limited to 'src')
-rw-r--r--src/Propellor/Property/Dns.hs13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/Propellor/Property/Dns.hs b/src/Propellor/Property/Dns.hs
index b85c7158..63752590 100644
--- a/src/Propellor/Property/Dns.hs
+++ b/src/Propellor/Property/Dns.hs
@@ -39,6 +39,9 @@ import Data.List
-- Will cause that hostmame and its alias to appear in the zone file,
-- with the configured IP address.
--
+-- Also, if a host has a ssh public key configured, a SSHFP record will
+-- be automatically generated for it.
+--
-- The [(BindDomain, Record)] list can be used for additional records
-- that cannot be configured elsewhere. This often includes NS records,
-- TXT records and perhaps CNAMEs pointing at hosts that propellor does
@@ -77,8 +80,7 @@ setupPrimary zonefile mknamedconffile hosts domain soa rs =
baseprop = Property ("dns primary for " ++ domain) satisfy
(addNamedConf conf)
satisfy = do
- sshfps <- zip (repeat (AbsDomain domain)) . concat
- <$> mapM genSSHFP indomain
+ sshfps <- concat <$> mapM genSSHFP indomain
let zone = partialzone
{ zHosts = zHosts partialzone ++ rs ++ sshfps }
ifM (liftIO $ needupdate zone)
@@ -419,10 +421,11 @@ type WarningMessage = String
-- ssh public keys.
--
-- This is done using ssh-keygen, so sadly needs IO.
-genSSHFP :: Host -> Propellor [Record]
-genSSHFP h = concat <$> (gen =<< get)
+genSSHFP :: Host -> Propellor [(BindDomain, Record)]
+genSSHFP h = map (\r -> (AbsDomain hostname, r)) . concat <$> (gen =<< get)
where
- get = fromHost [h] (hostName h) Ssh.getPubKey
+ hostname = hostName h
+ get = fromHost [h] hostname Ssh.getPubKey
gen = liftIO . mapM go . M.elems . fromMaybe M.empty
go pubkey = withTmpFile "sshfp" $ \tmp tmph -> do
hPutStrLn tmph pubkey