summaryrefslogtreecommitdiff
path: root/src/Propellor/Types.hs
diff options
context:
space:
mode:
authorJoey Hess2014-12-06 06:34:32 -0400
committerJoey Hess2014-12-06 06:34:32 -0400
commitfcff7762e395378791f01c9ea8507b41a4d7d501 (patch)
treec5f3c910e93a7741c3326e729140dbd8b210e36b /src/Propellor/Types.hs
parentc97dd0d7088fa981f762070e06fc8058ab04cdbd (diff)
endAction can be used to register an action to run once propellor has successfully run on a host.
Diffstat (limited to 'src/Propellor/Types.hs')
-rw-r--r--src/Propellor/Types.hs15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/Propellor/Types.hs b/src/Propellor/Types.hs
index 2f51b3e4..64cb5fbb 100644
--- a/src/Propellor/Types.hs
+++ b/src/Propellor/Types.hs
@@ -23,6 +23,8 @@ module Propellor.Types
, SshKeyType(..)
, Val(..)
, fromVal
+ , RunLog
+ , EndAction(..)
, module Propellor.Types.OS
, module Propellor.Types.Dns
) where
@@ -31,7 +33,7 @@ import Data.Monoid
import Control.Applicative
import System.Console.ANSI
import System.Posix.Types
-import "mtl" Control.Monad.Reader
+import "mtl" Control.Monad.RWS.Strict
import "MonadCatchIO-transformers" Control.Monad.CatchIO
import qualified Data.Set as S
import qualified Propellor.Types.Dns as Dns
@@ -52,13 +54,14 @@ data Host = Host
deriving (Show)
-- | Propellor's monad provides read-only access to info about the host
--- it's running on.
-newtype Propellor p = Propellor { runWithHost :: ReaderT Host IO p }
+-- it's running on, and a writer to accumulate logs about the run.
+newtype Propellor p = Propellor { runWithHost :: RWST Host RunLog () IO p }
deriving
( Monad
, Functor
, Applicative
, MonadReader Host
+ , MonadWriter RunLog
, MonadIO
, MonadCatchIO
)
@@ -197,3 +200,9 @@ instance Monoid (Val a) where
fromVal :: Val a -> Maybe a
fromVal (Val a) = Just a
fromVal NoVal = Nothing
+
+type RunLog = [EndAction]
+
+-- | An action that Propellor runs at the end, after trying to satisfy all
+-- properties.
+data EndAction = EndAction Desc (Propellor Result)