packages feed

hsfacter 0.1.0.3 → 0.2.0.0

raw patch · 2 files changed

+27/−4 lines, 2 filesdep +language-puppet

Dependencies added: language-puppet

Files

Facter.hs view
@@ -4,6 +4,10 @@ import Data.List import Text.Printf import qualified Data.Set as Set+import qualified Data.Map as Map+import Puppet.Interpreter.Types+import Puppet.Init+import PuppetDB.Rest  storageunits = [ ("", 0), ("K", 1), ("M", 2), ("G", 3), ("T", 4) ] @@ -90,5 +94,24 @@  version = return [("facterversion", "0.1"),("environment","test")] -allFacts :: IO [(String, String)]-allFacts = mapM id [factNET, factRAM, factOS, version, factMountPoints] >>= return . concat+allFacts :: String -> IO (Map.Map String ResolvedValue)+allFacts nodename = puppetDBFacts nodename "http://localhost:8080"++puppetDBFacts :: String -> String -> IO (Map.Map String ResolvedValue)+puppetDBFacts nodename url = do+        puppetDBFacts <- rawRequest url "facts" nodename+        case puppetDBFacts of+            Right (ResolvedHash xs) ->+                let myhash = case (filter ((=="facts") . fst) xs) of+                                 [(_, ResolvedHash pfacts)] -> Map.fromList $ concatMap (\(a,b) -> [(a,b), ("::" ++ a, b)]) pfacts+                                 _ -> error $ "Bad facts format: " ++ show xs+                in  return myhash+            _ -> do+                rawFacts <- mapM id [factNET, factRAM, factOS, version, factMountPoints] >>= return . concat+                let ofacts = genFacts rawFacts+                    (hostname, ddomainname) = break (== '.') nodename+                    domainname = tail $ ddomainname+                    nfacts = genFacts [("fqdn", nodename), ("hostname", hostname), ("domain", domainname), ("rootrsa", "xxx")]+                    allfacts = Map.union nfacts ofacts+                return allfacts+
hsfacter.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/  name:                hsfacter-version:             0.1.0.3+version:             0.2.0.0 synopsis:            A small and ugly library that emulates the output of the puppet facter program. description:         This is a reimplementation of the facter module used by Puppet, as a library. It is supposed to be used in conjunction with the language-puppet library in order to compute catalogs. license:             GPL-3@@ -18,4 +18,4 @@ library   exposed-modules:     Facter --  other-modules:       -  build-depends:       base >=4 && <5,containers+  build-depends:       base >=4 && <5,containers, language-puppet >= 0.1.7.3