summaryrefslogtreecommitdiff
path: root/src/Propellor/Attr.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Propellor/Attr.hs')
-rw-r--r--src/Propellor/Attr.hs11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/Propellor/Attr.hs b/src/Propellor/Attr.hs
index 29d7a01e..3ed59437 100644
--- a/src/Propellor/Attr.hs
+++ b/src/Propellor/Attr.hs
@@ -15,12 +15,15 @@ import Control.Applicative
pureAttrProperty :: Desc -> Attr -> Property
pureAttrProperty desc = Property ("has " ++ desc) (return NoChange)
+askAttr :: (Attr -> Val a) -> Propellor (Maybe a)
+askAttr f = asks (fromVal . f . hostAttr)
+
os :: System -> Property
os system = pureAttrProperty ("Operating " ++ show system) $
- mempty { _os = Just system }
+ mempty { _os = Val system }
getOS :: Propellor (Maybe System)
-getOS = asks (_os . hostAttr)
+getOS = askAttr _os
-- | Indidate that a host has an A record in the DNS.
--
@@ -55,10 +58,10 @@ addDNS r = pureAttrProperty (rdesc r) $
sshPubKey :: String -> Property
sshPubKey k = pureAttrProperty ("ssh pubkey known") $
- mempty { _sshPubKey = Just k }
+ mempty { _sshPubKey = Val k }
getSshPubKey :: Propellor (Maybe String)
-getSshPubKey = asks (_sshPubKey . hostAttr)
+getSshPubKey = askAttr _sshPubKey
hostMap :: [Host] -> M.Map HostName Host
hostMap l = M.fromList $ zip (map hostName l) l