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/Spin.hs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/Propellor/Spin.hs') diff --git a/src/Propellor/Spin.hs b/src/Propellor/Spin.hs index ecefbf6e..401c9375 100644 --- a/src/Propellor/Spin.hs +++ b/src/Propellor/Spin.hs @@ -40,8 +40,8 @@ commitSpin = do void $ actionMessage "Push to central git repository" $ boolSystem "git" [Param "push"] -spin :: HostName -> Maybe HostName -> Host -> IO () -spin target relay hst = do +spin :: HostName -> Maybe HostName -> ControllerChain -> Host -> IO () +spin target relay cc hst = do cacheparams <- if viarelay then pure ["-A"] else toCommand <$> sshCachingParams hn @@ -89,7 +89,9 @@ spin target relay hst = do runcmd = "cd " ++ localdir ++ " && ./propellor " ++ cmd cmd = if viarelay then "--serialized " ++ shellEscape (show (Spin [target] (Just target))) - else "--continue " ++ shellEscape (show (SimpleRun target)) + else if cc == mempty + then "--continue " ++ shellEscape (show (SimpleRun target)) + else "--continue " ++ shellEscape (show (ControlledRun target cc)) -- Check if the Host contains an IP address that matches one of the IPs -- in the DNS for the HostName. If so, the HostName is used as-is, -- cgit v1.2.3