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/CmdLine.hs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/Propellor/CmdLine.hs') diff --git a/src/Propellor/CmdLine.hs b/src/Propellor/CmdLine.hs index 33bb0bdc..35929ea7 100644 --- a/src/Propellor/CmdLine.hs +++ b/src/Propellor/CmdLine.hs @@ -115,11 +115,14 @@ defaultMain hostlist = do go True cmdline = updateFirst cmdline $ go False cmdline go False (Spin hs r) = do commitSpin - forM_ hs $ \hn -> withhost hn $ spin hn r + forM_ hs $ \hn -> withhost hn $ + spin hn r mempty go False cmdline@(SimpleRun hn) = buildFirst cmdline $ go False (Run hn) + go False cmdline@(ControlledRun hn cc) = buildFirst cmdline $ + onlyprocess $ withhost hn $ mainProperties cc go False (Run hn) = ifM ((==) 0 <$> getRealUserID) - ( onlyprocess $ withhost hn mainProperties + ( onlyprocess $ withhost hn $ mainProperties mempty , go True (Spin [hn] Nothing) ) -- cgit v1.2.3