From e66b62f40bcb29ca62c905dabe87cc6e91a6bccd Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 16 Oct 2015 14:20:13 -0400 Subject: Added Propellor.Property.Spin, which can be used to make a host be a controller of other hosts. The hard part of this is avoiding loops of controllers. To make that work, a ControllerChain is passed to the host that's spun, and is added to the Info of the host being spun, where the controller property can check it to detect an avoid a loop. That needed an expansion of the CmdLine data type. I made the new ControlledRun only be used when there is a ControllerChain provided. This avoids breaking backwards compatability with old propellor deployments, as --spin still uses SimpleRun. Note: Making an old propellor deployment be controlled by a controller won't work until it's been updated to this commit, so it knows about the ControlledRun parameter. (Untested) --- src/Propellor/Engine.hs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/Propellor/Engine.hs') diff --git a/src/Propellor/Engine.hs b/src/Propellor/Engine.hs index 0fdbb995..87fa4cd2 100644 --- a/src/Propellor/Engine.hs +++ b/src/Propellor/Engine.hs @@ -26,6 +26,8 @@ import Propellor.Types import Propellor.Message import Propellor.Exception import Propellor.Info +import Propellor.Types.Info +import Propellor.Types.CmdLine import Propellor.Property import Utility.Exception import Utility.PartialPrelude @@ -33,9 +35,9 @@ import Utility.Monad -- | Gets the Properties of a Host, and ensures them all, -- with nice display of what's being done. -mainProperties :: Host -> IO () -mainProperties host = do - ret <- runPropellor host $ +mainProperties :: ControllerChain -> Host -> IO () +mainProperties cc host = do + ret <- runPropellor host' $ ensureProperties [ignoreInfo $ infoProperty "overall" (ensureProperties ps) mempty mempty] h <- mkMessageHandle whenConsole h $ @@ -45,7 +47,8 @@ mainProperties host = do FailedChange -> exitWith (ExitFailure 1) _ -> exitWith ExitSuccess where - ps = map ignoreInfo $ hostProperties host + ps = map ignoreInfo $ hostProperties host' + host' = addHostInfo host (InfoVal cc) -- | Runs a Propellor action with the specified host. -- -- cgit v1.3-2-g0d8e