From fcff7762e395378791f01c9ea8507b41a4d7d501 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sat, 6 Dec 2014 06:34:32 -0400 Subject: endAction can be used to register an action to run once propellor has successfully run on a host. --- src/Propellor/Property.hs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/Propellor/Property.hs') diff --git a/src/Propellor/Property.hs b/src/Propellor/Property.hs index 6ace5e4e..1533471e 100644 --- a/src/Propellor/Property.hs +++ b/src/Propellor/Property.hs @@ -7,7 +7,7 @@ import System.FilePath import Control.Monad import Data.Monoid import Control.Monad.IfElse -import "mtl" Control.Monad.Reader +import "mtl" Control.Monad.RWS.Strict import Propellor.Types import Propellor.Info @@ -131,11 +131,11 @@ boolProperty desc a = property desc $ ifM (liftIO a) revert :: RevertableProperty -> RevertableProperty revert (RevertableProperty p1 p2) = RevertableProperty p2 p1 --- Changes the action that is performed to satisfy a property. +-- | Changes the action that is performed to satisfy a property. adjustProperty :: Property -> (Propellor Result -> Propellor Result) -> Property adjustProperty p f = p { propertySatisfy = f (propertySatisfy p) } --- Combines the Info of two properties. +-- | Combines the Info of two properties. combineInfo :: (IsProp p, IsProp q) => p -> q -> Info combineInfo p q = getInfo p <> getInfo q @@ -147,3 +147,8 @@ makeChange a = liftIO a >> return MadeChange noChange :: Propellor Result noChange = return NoChange + +-- | Registers an action that should be run at the very end, +-- and only when all configured Properties of the host succeed. +endAction :: Desc -> Propellor Result -> Propellor () +endAction desc a = tell [EndAction desc a] -- cgit v1.2.3