api doc improvements

This commit is contained in:
Joey Hess 2014-04-03 02:27:17 -04:00
parent 9a9f249ff0
commit fdb48b1dd1
Failed to extract signature
7 changed files with 27 additions and 20 deletions

View File

@ -46,12 +46,11 @@ debCdn = binandsrc "http://cdn.debian.net/debian"
kernelOrg :: DebianSuite -> [Line] kernelOrg :: DebianSuite -> [Line]
kernelOrg = binandsrc "http://mirrors.kernel.org/debian" kernelOrg = binandsrc "http://mirrors.kernel.org/debian"
{- | Makes sources.list have a standard content using the mirror CDN, -- | Makes sources.list have a standard content using the mirror CDN,
- with a particular DebianSuite. -- with a particular DebianSuite.
- --
- Since the CDN is sometimes unreliable, also adds backup lines using -- Since the CDN is sometimes unreliable, also adds backup lines using
- kernel.org. -- kernel.org.
-}
stdSourcesList :: DebianSuite -> Property stdSourcesList :: DebianSuite -> Property
stdSourcesList suite = setSourcesList (debCdn suite ++ kernelOrg suite) stdSourcesList suite = setSourcesList (debCdn suite ++ kernelOrg suite)
`describe` ("standard sources.list for " ++ show suite) `describe` ("standard sources.list for " ++ show suite)
@ -113,7 +112,7 @@ buildDepIn dir = go `requires` installedMin ["devscripts", "equivs"]
noninteractiveEnv noninteractiveEnv
-- | Package installation may fail becuse the archive has changed. -- | Package installation may fail becuse the archive has changed.
-- Run an update in that case and retry. -} -- Run an update in that case and retry.
robustly :: Property -> Property robustly :: Property -> Property
robustly p = Property (propertyDesc p) $ do robustly p = Property (propertyDesc p) $ do
r <- ensureProperty p r <- ensureProperty p

View File

@ -41,7 +41,7 @@ scriptProperty script = cmdProperty "sh" ["-c", shellcmd]
shellcmd = intercalate " ; " ("set -e" : script) shellcmd = intercalate " ; " ("set -e" : script)
-- | A property that can satisfied by running a series of shell commands, -- | A property that can satisfied by running a series of shell commands,
-- as user (staring in their home directory). -- as user (cd'd to their home directory).
userScriptProperty :: UserName -> [String] -> Property userScriptProperty :: UserName -> [String] -> Property
userScriptProperty user script = cmdProperty "su" ["-c", shellcmd, user] userScriptProperty user script = cmdProperty "su" ["-c", shellcmd, user]
where where

View File

@ -19,7 +19,7 @@ f `containsLine` l = fileProperty (f ++ " contains:" ++ l) go f
-- | Ensures that a line is not present in a file. -- | Ensures that a line is not present in a file.
-- Note that the file is ensured to exist, so if it doesn't, an empty -- Note that the file is ensured to exist, so if it doesn't, an empty
-- file will be written. -} -- file will be written.
lacksLine :: FilePath -> Line -> Property lacksLine :: FilePath -> Line -> Property
f `lacksLine` l = fileProperty (f ++ " remove: " ++ l) (filter (/= l)) f f `lacksLine` l = fileProperty (f ++ " remove: " ++ l) (filter (/= l)) f

View File

@ -23,5 +23,7 @@ ipv6to4 = fileProperty "ipv6to4" go interfaces
, "# End automatically added by propeller" , "# End automatically added by propeller"
] ]
ifUp :: String -> Property type Interface = String
ifUp :: Interface -> Property
ifUp iface = cmdProperty "ifup" [iface] ifUp iface = cmdProperty "ifup" [iface]

View File

@ -1,4 +1,11 @@
module Propellor.Property.Ssh where module Propellor.Property.Ssh (
setSshdConfig,
permitRootLogin,
passwordAuthentication,
hasAuthorizedKeys,
restartSshd,
uniqueHostKeys
) where
import Propellor import Propellor
import qualified Propellor.Property.File as File import qualified Propellor.Property.File as File
@ -38,8 +45,9 @@ hasAuthorizedKeys = go <=< homedir
restartSshd :: Property restartSshd :: Property
restartSshd = cmdProperty "service" ["ssh", "restart"] restartSshd = cmdProperty "service" ["ssh", "restart"]
{- | Blow away existing host keys and make new ones. Use a flag -- | Blows away existing host keys and make new ones.
- file to prevent doing this more than once. -} -- Useful for systems installed from an image that might reuse host keys.
-- A flag file is used to only ever do this once.
uniqueHostKeys :: Property uniqueHostKeys :: Property
uniqueHostKeys = flagFile prop "/etc/ssh/.unique_host_keys" uniqueHostKeys = flagFile prop "/etc/ssh/.unique_host_keys"
`onChange` restartSshd `onChange` restartSshd

View File

@ -7,11 +7,8 @@ import Propellor.Property.File
import qualified Propellor.Property.Apt as Apt import qualified Propellor.Property.Apt as Apt
import Propellor.Property.User import Propellor.Property.User
{- | Allows a user to sudo. If the user has a password, sudo is configured -- | Allows a user to sudo. If the user has a password, sudo is configured
- to require it. If not, NOPASSWORD is enabled for the user. -- to require it. If not, NOPASSWORD is enabled for the user.
-
- TOOD: Full sudoers file format parse..
-}
enabledFor :: UserName -> Property enabledFor :: UserName -> Property
enabledFor user = Property desc go `requires` Apt.installed ["sudo"] enabledFor user = Property desc go `requires` Apt.installed ["sudo"]
where where
@ -26,6 +23,7 @@ enabledFor user = Property desc go `requires` Apt.installed ["sudo"]
sudoline True = sudobaseline ++ " NOPASSWD:ALL" sudoline True = sudobaseline ++ " NOPASSWD:ALL"
sudoline False = sudobaseline ++ " ALL" sudoline False = sudobaseline ++ " ALL"
wanted locked l wanted locked l
-- TOOD: Full sudoers file format parse..
| not (sudobaseline `isPrefixOf` l) = True | not (sudobaseline `isPrefixOf` l) = True
| "NOPASSWD" `isInfixOf` l = locked | "NOPASSWD" `isInfixOf` l = locked
| otherwise = True | otherwise = True

View File

@ -79,13 +79,13 @@ Library
Propellor.Property.SiteSpecific.GitHome Propellor.Property.SiteSpecific.GitHome
Propellor.Property.SiteSpecific.JoeySites Propellor.Property.SiteSpecific.JoeySites
Propellor.Property.SiteSpecific.GitAnnexBuilder Propellor.Property.SiteSpecific.GitAnnexBuilder
Propellor.CmdLine
Propellor.Message Propellor.Message
Propellor.PrivData Propellor.PrivData
Propellor.Engine Propellor.Engine
Propellor.SimpleSh
Propellor.Types Propellor.Types
Other-Modules: Other-Modules:
Propellor.CmdLine
Propellor.SimpleSh
Utility.Applicative Utility.Applicative
Utility.Data Utility.Data
Utility.Directory Utility.Directory