summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJoey Hess2014-11-21 01:05:51 -0400
committerJoey Hess2014-11-21 01:05:51 -0400
commita904476333bcacfbed5d0ca95e8f8b3cca9fb327 (patch)
treea28338d121527f41d1cd776c3dc16b521ec8da73 /src
parent9f9a4c653fcd7ef82bf5fa066fa7b270b2855b93 (diff)
avoid console output when chaining into chroot and not at console
Diffstat (limited to 'src')
-rw-r--r--src/Propellor/CmdLine.hs2
-rw-r--r--src/Propellor/Property/Chroot.hs15
-rw-r--r--src/Propellor/Types.hs2
3 files changed, 11 insertions, 8 deletions
diff --git a/src/Propellor/CmdLine.hs b/src/Propellor/CmdLine.hs
index 466b60f5..a26e2559 100644
--- a/src/Propellor/CmdLine.hs
+++ b/src/Propellor/CmdLine.hs
@@ -85,8 +85,8 @@ defaultMain hostlist = do
go _ (Edit field context) = editPrivData field context
go _ ListFields = listPrivDataFields hostlist
go _ (AddKey keyid) = addKey keyid
+ go _ (ChrootChain hn loc onconsole) = Chroot.chain hostlist hn loc onconsole
go _ (DockerChain hn cid) = Docker.chain hostlist hn cid
- go _ (ChrootChain hn loc) = Chroot.chain hostlist hn loc
go _ (DockerInit hn) = Docker.init hn
go _ (GitPush fin fout) = gitPushHelper fin fout
go _ (Update _) = forceConsole >> fetchFirst (onlyprocess update)
diff --git a/src/Propellor/Property/Chroot.hs b/src/Propellor/Property/Chroot.hs
index 798330b0..e6c2c84e 100644
--- a/src/Propellor/Property/Chroot.hs
+++ b/src/Propellor/Property/Chroot.hs
@@ -89,19 +89,22 @@ provisionChroot c@(Chroot loc _ _) = property (chrootDesc c "provisioned") $ do
chainprovision shim = do
parenthost <- asks hostName
+ cmd <- liftIO $ toChain parenthost c
let p = inChrootProcess c
[ shim
, "--continue"
- , show $ toChain parenthost c
+ , show cmd
]
liftIO $ withHandle StdoutHandle createProcessSuccess p
processChainOutput
-toChain :: HostName -> Chroot -> CmdLine
-toChain parenthost (Chroot loc _ _) = ChrootChain parenthost loc
+toChain :: HostName -> Chroot -> IO CmdLine
+toChain parenthost (Chroot loc _ _) = do
+ onconsole <- isConsole <$> mkMessageHandle
+ return $ ChrootChain parenthost loc onconsole
-chain :: [Host] -> HostName -> FilePath -> IO ()
-chain hostlist hn loc = case findHostNoAlias hostlist hn of
+chain :: [Host] -> HostName -> FilePath -> Bool -> IO ()
+chain hostlist hn loc onconsole = case findHostNoAlias hostlist hn of
Nothing -> errorMessage ("cannot find host " ++ hn)
Just parenthost -> case M.lookup loc (_chroots $ _chrootinfo $ hostInfo parenthost) of
Nothing -> errorMessage ("cannot find chroot " ++ loc ++ " on host " ++ hn)
@@ -109,7 +112,7 @@ chain hostlist hn loc = case findHostNoAlias hostlist hn of
where
go h = do
changeWorkingDirectory localdir
- forceConsole
+ when onconsole forceConsole
onlyProcess (provisioningLock loc) $ do
r <- runPropellor h $ ensureProperties $ hostProperties h
putStrLn $ "\n" ++ show r
diff --git a/src/Propellor/Types.hs b/src/Propellor/Types.hs
index 56eafc6d..65dbd3c5 100644
--- a/src/Propellor/Types.hs
+++ b/src/Propellor/Types.hs
@@ -155,7 +155,7 @@ data CmdLine
| Update HostName
| DockerInit HostName
| DockerChain HostName String
- | ChrootChain HostName FilePath
+ | ChrootChain HostName FilePath Bool
| GitPush Fd Fd
deriving (Read, Show, Eq)