From fdb48b1dd11b802d0c2124fb3833672ca87ab870 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 3 Apr 2014 02:27:17 -0400 Subject: api doc improvements --- Propellor/Property/Apt.hs | 13 ++++++------- Propellor/Property/Cmd.hs | 2 +- Propellor/Property/File.hs | 2 +- Propellor/Property/Network.hs | 4 +++- Propellor/Property/Ssh.hs | 14 +++++++++++--- Propellor/Property/Sudo.hs | 8 +++----- 6 files changed, 25 insertions(+), 18 deletions(-) (limited to 'Propellor/Property') diff --git a/Propellor/Property/Apt.hs b/Propellor/Property/Apt.hs index d3c5044a..8bbb1b19 100644 --- a/Propellor/Property/Apt.hs +++ b/Propellor/Property/Apt.hs @@ -46,12 +46,11 @@ debCdn = binandsrc "http://cdn.debian.net/debian" kernelOrg :: DebianSuite -> [Line] kernelOrg = binandsrc "http://mirrors.kernel.org/debian" -{- | Makes sources.list have a standard content using the mirror CDN, - - with a particular DebianSuite. - - - - Since the CDN is sometimes unreliable, also adds backup lines using - - kernel.org. - -} +-- | Makes sources.list have a standard content using the mirror CDN, +-- with a particular DebianSuite. +-- +-- Since the CDN is sometimes unreliable, also adds backup lines using +-- kernel.org. stdSourcesList :: DebianSuite -> Property stdSourcesList suite = setSourcesList (debCdn suite ++ kernelOrg suite) `describe` ("standard sources.list for " ++ show suite) @@ -113,7 +112,7 @@ buildDepIn dir = go `requires` installedMin ["devscripts", "equivs"] noninteractiveEnv -- | 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 p = Property (propertyDesc p) $ do r <- ensureProperty p diff --git a/Propellor/Property/Cmd.hs b/Propellor/Property/Cmd.hs index 1f668daf..dc5073d3 100644 --- a/Propellor/Property/Cmd.hs +++ b/Propellor/Property/Cmd.hs @@ -41,7 +41,7 @@ scriptProperty script = cmdProperty "sh" ["-c", shellcmd] shellcmd = intercalate " ; " ("set -e" : script) -- | 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 user script = cmdProperty "su" ["-c", shellcmd, user] where diff --git a/Propellor/Property/File.hs b/Propellor/Property/File.hs index 4312b89d..af4f554f 100644 --- a/Propellor/Property/File.hs +++ b/Propellor/Property/File.hs @@ -19,7 +19,7 @@ f `containsLine` l = fileProperty (f ++ " contains:" ++ l) go f -- | 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 --- file will be written. -} +-- file will be written. lacksLine :: FilePath -> Line -> Property f `lacksLine` l = fileProperty (f ++ " remove: " ++ l) (filter (/= l)) f diff --git a/Propellor/Property/Network.hs b/Propellor/Property/Network.hs index cbef8baa..eae5828f 100644 --- a/Propellor/Property/Network.hs +++ b/Propellor/Property/Network.hs @@ -23,5 +23,7 @@ ipv6to4 = fileProperty "ipv6to4" go interfaces , "# End automatically added by propeller" ] -ifUp :: String -> Property +type Interface = String + +ifUp :: Interface -> Property ifUp iface = cmdProperty "ifup" [iface] diff --git a/Propellor/Property/Ssh.hs b/Propellor/Property/Ssh.hs index 28fe45f6..36766f56 100644 --- a/Propellor/Property/Ssh.hs +++ b/Propellor/Property/Ssh.hs @@ -1,4 +1,11 @@ -module Propellor.Property.Ssh where +module Propellor.Property.Ssh ( + setSshdConfig, + permitRootLogin, + passwordAuthentication, + hasAuthorizedKeys, + restartSshd, + uniqueHostKeys +) where import Propellor import qualified Propellor.Property.File as File @@ -38,8 +45,9 @@ hasAuthorizedKeys = go <=< homedir restartSshd :: Property restartSshd = cmdProperty "service" ["ssh", "restart"] -{- | Blow away existing host keys and make new ones. Use a flag - - file to prevent doing this more than once. -} +-- | Blows away existing host keys and make new ones. +-- 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 = flagFile prop "/etc/ssh/.unique_host_keys" `onChange` restartSshd diff --git a/Propellor/Property/Sudo.hs b/Propellor/Property/Sudo.hs index dbb3e460..68b8d056 100644 --- a/Propellor/Property/Sudo.hs +++ b/Propellor/Property/Sudo.hs @@ -7,11 +7,8 @@ import Propellor.Property.File import qualified Propellor.Property.Apt as Apt import Propellor.Property.User -{- | 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. - - - - TOOD: Full sudoers file format parse.. - -} +-- | 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. enabledFor :: UserName -> Property enabledFor user = Property desc go `requires` Apt.installed ["sudo"] where @@ -26,6 +23,7 @@ enabledFor user = Property desc go `requires` Apt.installed ["sudo"] sudoline True = sudobaseline ++ " NOPASSWD:ALL" sudoline False = sudobaseline ++ " ALL" wanted locked l + -- TOOD: Full sudoers file format parse.. | not (sudobaseline `isPrefixOf` l) = True | "NOPASSWD" `isInfixOf` l = locked | otherwise = True -- cgit v1.2.3