propellor spin
This commit is contained in:
parent
0f08c035c7
commit
d71f8caad4
|
@ -92,6 +92,19 @@ check c property = Property (propertyDesc property) $ ifM (liftIO c)
|
|||
, return NoChange
|
||||
)
|
||||
|
||||
-- | Marks a Property as trivial. It can only return FailedChange or
|
||||
-- NoChange.
|
||||
--
|
||||
-- Useful when it's just as expensive to check if a change needs
|
||||
-- to be made as it is to just idempotently assure the property is
|
||||
-- satisfied. For example, chmodding a file.
|
||||
trivial :: Property -> Property
|
||||
trivial p = Property (propertyDesc p) $ do
|
||||
r <- ensureProperty p
|
||||
if r == MadeChange
|
||||
then return NoChange
|
||||
else return r
|
||||
|
||||
-- | Makes a property that is satisfied differently depending on the host's
|
||||
-- operating system.
|
||||
--
|
||||
|
|
|
@ -10,12 +10,12 @@ type ConfigFile = [String]
|
|||
siteEnabled :: HostName -> ConfigFile -> RevertableProperty
|
||||
siteEnabled hn cf = RevertableProperty enable disable
|
||||
where
|
||||
enable = cmdProperty "a2ensite" ["--quiet", hn]
|
||||
enable = trivial $ cmdProperty "a2ensite" ["--quiet", hn]
|
||||
`describe` ("apache site enabled " ++ hn)
|
||||
`requires` siteAvailable hn cf
|
||||
`requires` installed
|
||||
`onChange` reloaded
|
||||
disable = File.notPresent (siteCfg hn)
|
||||
disable = trivial $ File.notPresent (siteCfg hn)
|
||||
`describe` ("apache site disabled " ++ hn)
|
||||
`onChange` cmdProperty "a2dissite" ["--quiet", hn]
|
||||
`requires` installed
|
||||
|
@ -30,11 +30,11 @@ siteAvailable hn cf = siteCfg hn `File.hasContent` (comment:cf)
|
|||
modEnabled :: String -> RevertableProperty
|
||||
modEnabled modname = RevertableProperty enable disable
|
||||
where
|
||||
enable = cmdProperty "a2enmod" ["--quiet", modname]
|
||||
enable = trivial $ cmdProperty "a2enmod" ["--quiet", modname]
|
||||
`describe` ("apache module enabled " ++ modname)
|
||||
`requires` installed
|
||||
`onChange` reloaded
|
||||
disable = cmdProperty "a2dismod" ["--quiet", modname]
|
||||
disable = trivial $ cmdProperty "a2dismod" ["--quiet", modname]
|
||||
`describe` ("apache module disabled " ++ modname)
|
||||
`requires` installed
|
||||
`onChange` reloaded
|
||||
|
|
|
@ -103,7 +103,7 @@ installed' params ps = robustly $ check (isInstallable ps) go
|
|||
go = runApt $ params ++ ["install"] ++ ps
|
||||
|
||||
installedBackport :: [Package] -> Property
|
||||
installedBackport ps = withOS desc $ \o -> case o of
|
||||
installedBackport ps = trivial $ withOS desc $ \o -> case o of
|
||||
Nothing -> error "cannot install backports; os not declared"
|
||||
(Just (System (Debian suite) _))
|
||||
| isStable suite ->
|
||||
|
|
Loading…
Reference in New Issue