From 91610aee8f34bb10959bdf6a6e5b16c895c7c1c2 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 16 Oct 2015 19:06:29 -0400 Subject: improve ssh user key properties * Ssh.keyImported is replaced with Ssh.userKeys. (API change) The new property only gets the private key from the privdata; the public key is provided as a parameter, and so is available as Info that other properties can use. * Ssh.keyImported' is renamed to Ssh.userKeyAt, and also changed to only import the private key from the privdata. (API change) * While Ssh.keyImported and Ssh.keyImported' avoided updating existing keys, the new Ssh.userKeys and Ssh.userKeyAt properties will always update out of date key files. * Ssh.pubKey renamed to Ssh.hostPubKey. (API change) This makes eg, setting up ssh for spin controllers work better. --- src/Propellor/Engine.hs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'src/Propellor/Engine.hs') diff --git a/src/Propellor/Engine.hs b/src/Propellor/Engine.hs index 87fa4cd2..021ddd2c 100644 --- a/src/Propellor/Engine.hs +++ b/src/Propellor/Engine.hs @@ -7,6 +7,7 @@ module Propellor.Engine ( ensureProperty, ensureProperties, fromHost, + fromHost', onlyProcess, processChainOutput, ) where @@ -76,17 +77,19 @@ ensureProperties ps = ensure ps NoChange r <- actionMessageOn hn (propertyDesc p) (ensureProperty p) ensure ls (r <> rs) --- | Lifts an action into a different host. +-- | Lifts an action into the context of a different host. -- --- > fromHost hosts "otherhost" getPubKey +-- > fromHost hosts "otherhost" Ssh.getHostPubKey fromHost :: [Host] -> HostName -> Propellor a -> Propellor (Maybe a) fromHost l hn getter = case findHost l hn of Nothing -> return Nothing - Just h -> do - (ret, _s, runlog) <- liftIO $ - runRWST (runWithHost getter) h () - tell runlog - return (Just ret) + Just h -> Just <$> fromHost' h getter + +fromHost' :: Host -> Propellor a -> Propellor a +fromHost' h getter = do + (ret, _s, runlog) <- liftIO $ runRWST (runWithHost getter) h () + tell runlog + return ret onlyProcess :: FilePath -> IO a -> IO a onlyProcess lockfile a = bracket lock unlock (const a) -- cgit v1.3-2-g0d8e