summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoey Hess2014-12-04 16:21:09 -0400
committerJoey Hess2014-12-04 16:21:09 -0400
commit0aa635dbd2412b02e38385376f27adfb7962c974 (patch)
treeb88b4baa7999296f6fb208733cf656d73a1d2b70
parentb5af98d744cd2a615eaa47cb8e55c673fa5289d0 (diff)
propellor spin
-rw-r--r--src/Propellor/Property/OS.hs24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/Propellor/Property/OS.hs b/src/Propellor/Property/OS.hs
index ce8f44f6..8f852bbd 100644
--- a/src/Propellor/Property/OS.hs
+++ b/src/Propellor/Property/OS.hs
@@ -52,7 +52,7 @@ import qualified Propellor.Property.User as User
-- > -- rest of system properties here
cleanInstallOnce :: Confirmation -> Property
cleanInstallOnce confirmation = check (not <$> doesFileExist flagfile) $
- confirmed
+ confirmed "clean install confirmed" confirmation
`before`
osbootstrapped
`before`
@@ -64,10 +64,6 @@ cleanInstallOnce confirmation = check (not <$> doesFileExist flagfile) $
`before`
finalized
where
- confirmed = property "clean install confirmed" $ do
- checkConfirmed confirmation
- return NoChange
-
osbootstrapped = withOS "/new-os bootstrapped" $ \o -> case o of
(Just d@(System (Debian _) _)) -> debootstrap d
(Just u@(System (Ubuntu _) _)) -> debootstrap u
@@ -97,11 +93,14 @@ cleanInstallOnce confirmation = check (not <$> doesFileExist flagfile) $
data Confirmation = Confirmed HostName
-checkConfirmed :: Confirmation -> Propellor ()
-checkConfirmed (Confirmed c) = do
+confirmed :: Desc -> Confirmation -> Property
+confirmed desc (Confirmed c) = property desc $ do
hostname <- asks hostName
- when (hostname /= c) $
- errorMessage "Run with a bad confirmation, not matching hostname."
+ if hostname /= c
+ then do
+ warningMessage "Run with a bad confirmation, not matching hostname."
+ return FailedChange
+ else return NoChange
-- /etc/network/interfaces is configured to bring up all interfaces that
-- are currently up, using the same IP addresses.
@@ -142,9 +141,10 @@ type GrubDev = String
-- Removes the old OS's backup from /old-os
oldOSRemoved :: Confirmation -> Property
-oldOSRemoved confirmed = check (doesDirectoryExist oldOsDir) $
- property "old OS backup removed" $ do
- checkConfirmed confirmed
+oldOSRemoved confirmation = check (doesDirectoryExist oldOsDir) $
+ go `requires` confirmed "old OS backup removal confirmed" confirmation
+ where
+ go = property "old OS backup removed" $ do
liftIO $ removeDirectoryRecursive oldOsDir
return MadeChange