summaryrefslogtreecommitdiff
path: root/src/Propellor/Engine.hs
diff options
context:
space:
mode:
authorJoey Hess2015-10-16 19:50:37 -0400
committerJoey Hess2015-10-16 19:50:37 -0400
commitfe052464493571ac26d825823c8c6e95ddb096e2 (patch)
treec33ac0f27a3248db58c197b16a103009f554bf15 /src/Propellor/Engine.hs
parent06f4258f8174302a825a893b3407df9cff15c577 (diff)
parentf18304181f59f737f8034f6a5aa69b89829f1785 (diff)
Merge branch 'joeyconfig'
Diffstat (limited to 'src/Propellor/Engine.hs')
-rw-r--r--src/Propellor/Engine.hs17
1 files changed, 10 insertions, 7 deletions
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)