Safe Haskell | None |
---|---|
Language | Haskell98 |
- requires :: Combines x y => x -> y -> CombinedType x y
- before :: Combines x y => x -> y -> CombinedType x y
- onChange :: Combines x y => x -> y -> CombinedType x y
- onChangeFlagOnFail :: Combines x y => FilePath -> x -> y -> CombinedType x y
- flagFile :: Property i -> FilePath -> Property i
- flagFile' :: Property i -> IO FilePath -> Property i
- check :: (Checkable p i, LiftPropellor m) => m Bool -> p i -> Property i
- fallback :: Combines p1 p2 => p1 -> p2 -> CombinedType p1 p2
- revert :: RevertableProperty i -> RevertableProperty i
- describe :: IsProp p => p -> Desc -> p
- (==>) :: IsProp (Property i) => Desc -> Property i -> Property i
- data Propellor p
- property :: Desc -> Propellor Result -> Property NoInfo
- ensureProperty :: Property NoInfo -> Propellor Result
- withOS :: Desc -> (Maybe System -> Propellor Result) -> Property NoInfo
- makeChange :: IO () -> Propellor Result
- noChange :: Propellor Result
- doNothing :: Property NoInfo
- endAction :: Desc -> (Result -> Propellor Result) -> Propellor ()
- data UncheckedProperty i
- unchecked :: Property i -> UncheckedProperty i
- changesFile :: Checkable p i => p i -> FilePath -> Property i
- changesFileContent :: Checkable p i => p i -> FilePath -> Property i
- isNewerThan :: FilePath -> FilePath -> IO Bool
- checkResult :: (Checkable p i, LiftPropellor m) => m a -> (a -> m Result) -> p i -> Property i
- class Checkable p i
- assume :: Checkable p i => p i -> Result -> Property i
Property combinators
requires :: Combines x y => x -> y -> CombinedType x y Source
Indicates that the first property depends on the second, so before the first is ensured, the second must be ensured.
The combined property uses the description of the first property.
before :: Combines x y => x -> y -> CombinedType x y Source
Combines together two properties, resulting in one property that ensures the first, and if the first succeeds, ensures the second.
The combined property uses the description of the first property.
onChange :: Combines x y => x -> y -> CombinedType x y Source
Whenever a change has to be made for a Property, causes a hook Property to also be run, but not otherwise.
onChangeFlagOnFail :: Combines x y => FilePath -> x -> y -> CombinedType x y Source
Same as onChange
except that if property y fails, a flag file
is generated. On next run, if the flag file is present, property y
is executed even if property x doesn't change.
With onChange
, if y fails, the property x onChange
y returns
FailedChange
. But if this property is applied again, it returns
NoChange
. This behavior can cause trouble...
flagFile :: Property i -> FilePath -> Property i Source
Makes a perhaps non-idempotent Property be idempotent by using a flag file to indicate whether it has run before. Use with caution.
check :: (Checkable p i, LiftPropellor m) => m Bool -> p i -> Property i Source
Makes a Property
or an UncheckedProperty
only run
when a test succeeds.
fallback :: Combines p1 p2 => p1 -> p2 -> CombinedType p1 p2 Source
Tries the first property, but if it fails to work, instead uses the second.
revert :: RevertableProperty i -> RevertableProperty i Source
Undoes the effect of a RevertableProperty.
Property descriptions
(==>) :: IsProp (Property i) => Desc -> Property i -> Property i infixl 1 Source
Alias for flip describe
Constructing properties
Propellor's monad provides read-only access to info about the host it's running on, and a writer to accumulate EndActions.
property :: Desc -> Propellor Result -> Property NoInfo Source
Constructs a Property, from a description and an action to run to ensure the Property is met.
ensureProperty :: Property NoInfo -> Propellor Result Source
For when code running in the Propellor monad needs to ensure a Property.
This can only be used on a Property that has NoInfo.
withOS :: Desc -> (Maybe System -> Propellor Result) -> Property NoInfo Source
Makes a property that is satisfied differently depending on the host's operating system.
Note that the operating system may not be declared for all hosts.
myproperty = withOS "foo installed" $ \o -> case o of (Just (System (Debian suite) arch)) -> ... (Just (System (Ubuntu release) arch)) -> ... Nothing -> ...
makeChange :: IO () -> Propellor Result Source
endAction :: Desc -> (Result -> Propellor Result) -> Propellor () Source
Registers an action that should be run at the very end, after propellor has checks all the properties of a host.
Property result checking
data UncheckedProperty i Source
This is a Property
but its Result
is not accurate; in particular
it may return NoChange
despite having made a change.
However, when it returns MadeChange
, it really did make a change,
and FailedChange
is still an error.
unchecked :: Property i -> UncheckedProperty i Source
Use to indicate that a Property is unchecked.
changesFile :: Checkable p i => p i -> FilePath -> Property i Source
Indicates that a Property may change a particular file. When the file is modified in any way (including changing its permissions or mtime), the property will return MadeChange instead of NoChange.
changesFileContent :: Checkable p i => p i -> FilePath -> Property i Source
Like changesFile
, but compares the content of the file.
Changes to mtime etc that do not change file content are treated as
NoChange.
isNewerThan :: FilePath -> FilePath -> IO Bool Source
Determines if the first file is newer than the second file.
This can be used with check
to only run a command when a file
has changed.
check ("/etc/aliases" `isNewerThan` "/etc/aliases.db") (cmdProperty "newaliases" [] `assume` MadeChange) -- updates aliases.db
Or it can be used with checkResult
to test if a command made a change.
checkResult (return ()) (\_ -> "/etc/aliases.db" `isNewerThan` "/etc/aliases") (cmdProperty "newaliases" [])
(If one of the files does not exist, the file that does exist is considered to be the newer of the two.)
:: (Checkable p i, LiftPropellor m) | |
=> m a | Run before ensuring the property. |
-> (a -> m Result) | Run after ensuring the property. Return |
-> p i | |
-> Property i |
Checks the result of a property. Mostly used to convert a
UncheckedProperty
to a Property
, but can also be used to further
check a Property
.
checkedProp, preCheckedProp