more description improvements
This commit is contained in:
parent
4d33b25ba3
commit
afb7afee0c
|
@ -64,7 +64,8 @@ cleanCloudAtCost hostname = propertyList "cloudatcost cleanup"
|
||||||
`onChange` cmdProperty "update-grub" []
|
`onChange` cmdProperty "update-grub" []
|
||||||
`onChange` cmdProperty "update-initramfs" [Param "-u"]
|
`onChange` cmdProperty "update-initramfs" [Param "-u"]
|
||||||
`describe` "work around grub/lvm boot bug #743126"
|
`describe` "work around grub/lvm boot bug #743126"
|
||||||
-- Cruft
|
, combineProperties
|
||||||
, File.notPresent "/etc/rc.local"
|
[ File.notPresent "/etc/rc.local"
|
||||||
, File.notPresent "/etc/init.d/S97-setup.sh"
|
, File.notPresent "/etc/init.d/S97-setup.sh"
|
||||||
|
] `describe` "nuked cloudatcost cruft"
|
||||||
]
|
]
|
||||||
|
|
|
@ -43,8 +43,8 @@ propertyList desc ps = Property desc $ ensureProperties' ps
|
||||||
|
|
||||||
{- Combines a list of properties, resulting in one property that
|
{- Combines a list of properties, resulting in one property that
|
||||||
- ensures each in turn, stopping on failure. -}
|
- ensures each in turn, stopping on failure. -}
|
||||||
combineProperties :: Desc -> [Property] -> Property
|
combineProperties :: [Property] -> Property
|
||||||
combineProperties desc ps = Property desc $ go ps NoChange
|
combineProperties ps = Property desc $ go ps NoChange
|
||||||
where
|
where
|
||||||
go [] rs = return rs
|
go [] rs = return rs
|
||||||
go (l:ls) rs = do
|
go (l:ls) rs = do
|
||||||
|
@ -52,6 +52,9 @@ combineProperties desc ps = Property desc $ go ps NoChange
|
||||||
case r of
|
case r of
|
||||||
FailedChange -> return FailedChange
|
FailedChange -> return FailedChange
|
||||||
_ -> go ls (combineResult r rs)
|
_ -> go ls (combineResult r rs)
|
||||||
|
desc = case ps of
|
||||||
|
(p:_) -> propertyDesc p
|
||||||
|
_ -> "(empty)"
|
||||||
|
|
||||||
{- Makes a perhaps non-idempotent Property be idempotent by using a flag
|
{- Makes a perhaps non-idempotent Property be idempotent by using a flag
|
||||||
- file to indicate whether it has run before.
|
- file to indicate whether it has run before.
|
||||||
|
@ -81,7 +84,7 @@ property `onChange` hook = Property (propertyDesc property) $ do
|
||||||
{- Indicates that the first property can only be satisfied once
|
{- Indicates that the first property can only be satisfied once
|
||||||
- the second is. -}
|
- the second is. -}
|
||||||
requires :: Property -> Property -> Property
|
requires :: Property -> Property -> Property
|
||||||
x `requires` y = combineProperties (propertyDesc x) [y, x]
|
x `requires` y = combineProperties [y, x] `describe` propertyDesc x
|
||||||
|
|
||||||
describe :: Property -> Desc -> Property
|
describe :: Property -> Desc -> Property
|
||||||
describe p d = p { propertyDesc = d }
|
describe p d = p { propertyDesc = d }
|
||||||
|
|
|
@ -12,12 +12,13 @@ sshdConfig :: FilePath
|
||||||
sshdConfig = "/etc/ssh/sshd_config"
|
sshdConfig = "/etc/ssh/sshd_config"
|
||||||
|
|
||||||
setSshdConfig :: String -> Bool -> Property
|
setSshdConfig :: String -> Bool -> Property
|
||||||
setSshdConfig setting allowed = combineProperties desc
|
setSshdConfig setting allowed = combineProperties
|
||||||
[ sshdConfig `File.lacksLine` (sshline $ not allowed)
|
[ sshdConfig `File.lacksLine` (sshline $ not allowed)
|
||||||
, sshdConfig `File.containsLine` (sshline allowed)
|
, sshdConfig `File.containsLine` (sshline allowed)
|
||||||
] `onChange` restartSshd
|
]
|
||||||
|
`onChange` restartSshd
|
||||||
|
`describe` unwords [ "ssh config:", setting, sshBool allowed ]
|
||||||
where
|
where
|
||||||
desc = unwords [ "ssh config:", setting, sshBool allowed ]
|
|
||||||
sshline v = setting ++ " " ++ sshBool v
|
sshline v = setting ++ " " ++ sshBool v
|
||||||
|
|
||||||
permitRootLogin :: Bool -> Property
|
permitRootLogin :: Bool -> Property
|
||||||
|
|
Loading…
Reference in New Issue