diff options
| author | Evan Cofsky <evan@theunixman.com> | 2016-03-07 13:47:36 -0600 |
|---|---|---|
| committer | Evan Cofsky <evan@theunixman.com> | 2016-03-07 16:57:13 -0600 |
| commit | 14a208b02877459c56029ac87341dac632a8dc81 (patch) | |
| tree | d3ce2f877aa0cdce8241e246da08d6d8e41250c7 /src | |
| parent | ebdc52b23a01bab00bed2d837bf1d45c4589a483 (diff) | |
Fails on respin when it shouldn't recreate a Poudriere jail.
We were using checkResult instead of check, and we weren't parsing the
output of `jail -l -q` properly. Now it handles respins perfectly.
Diffstat (limited to 'src')
| -rw-r--r-- | src/Propellor/Property/FreeBSD/Poudriere.hs | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/src/Propellor/Property/FreeBSD/Poudriere.hs b/src/Propellor/Property/FreeBSD/Poudriere.hs index 3ebb4633..32234b27 100644 --- a/src/Propellor/Property/FreeBSD/Poudriere.hs +++ b/src/Propellor/Property/FreeBSD/Poudriere.hs @@ -1,5 +1,5 @@ -- | Maintainer: 2016 Evan Cofsky <evan@theunixman.com> --- +-- -- FreeBSD Poudriere properties {-# Language GeneralizedNewtypeDeriving #-} @@ -10,6 +10,7 @@ import Propellor.Base import Propellor.Types.Info import Data.List import Data.String (IsString(..)) +import Data.String.Utils (splitWs) import qualified Propellor.Property.FreeBSD.Pkg as Pkg import qualified Propellor.Property.ZFS as ZFS @@ -52,26 +53,27 @@ runPoudriere cmd args = lines <$> readProcess p a listJails :: IO [String] -listJails = runPoudriere "jail" ["-l", "-q"] +listJails = + map ((\(n:_) -> n ) . take 1 . splitWs) <$> runPoudriere "jail" ["-l", "-q"] jailExists :: Jail -> IO Bool jailExists (Jail name _ _) = isInfixOf [name] <$> listJails jail :: Jail -> Property NoInfo jail j@(Jail name version arch) = - checkResult chk (\_ -> return MadeChange) createJail + let + chk = do + c <- poudriereConfigured <$> askInfo + nx <- liftIO $ not <$> jailExists j + return $ c && nx + + (cmd, args) = poudriereCommand "jail" ["-c", "-j", name, "-a", show arch, "-v", show version] + createJail = cmdProperty cmd args + in + check chk createJail `describe` unwords ["Create poudriere jail", name] - where - cfgd = poudriereConfigured <$> askInfo - notExists :: IO Bool - notExists = not <$> jailExists j - chk = do - c <- cfgd - x <- liftIO notExists - return $ c && x - (cmd, args) = poudriereCommand "jail" ["-c", "-j", name, "-a", show arch, "-v", show version] - createJail = cmdProperty cmd args +data JailInfo = JailInfo String data Poudriere = Poudriere { _resolvConf :: String |
