summaryrefslogtreecommitdiff
path: root/Propellor/Attr.hs
diff options
context:
space:
mode:
authorJoey Hess2014-04-19 01:42:19 -0400
committerJoey Hess2014-04-19 01:42:19 -0400
commitf10c4d4aff6810a502cfc770013046e42efc33ef (patch)
treeb3ecd60d32166aca84dc0d72bbebff359778fa3e /Propellor/Attr.hs
parent9e578aca6b0914443c95f8691fd3ba39522f28fc (diff)
make primary dns server beat secondary if both are defined for a domain
Made my config file simpler..
Diffstat (limited to 'Propellor/Attr.hs')
-rw-r--r--Propellor/Attr.hs15
1 files changed, 13 insertions, 2 deletions
diff --git a/Propellor/Attr.hs b/Propellor/Attr.hs
index fb94dc34..05ea3ff5 100644
--- a/Propellor/Attr.hs
+++ b/Propellor/Attr.hs
@@ -49,10 +49,21 @@ alias domain = pureAttrProperty ("aka " ++ domain)
addDNS :: Record -> SetAttr
addDNS record d = d { _dns = S.insert record (_dns d) }
+-- | Adds a DNS NamedConf stanza.
+--
+-- Note that adding a Master stanza for a domain always overrides an
+-- existing Secondary stanza, while a Secondary stanza is only added
+-- when there is no existing Master stanza.
addNamedConf :: NamedConf -> SetAttr
-addNamedConf conf d = d { _namedconf = S.insert conf (_namedconf d) }
+addNamedConf conf d = d { _namedconf = new }
+ where
+ m = _namedconf d
+ domain = confDomain conf
+ new = case (confType conf, confType <$> M.lookup domain m) of
+ (Secondary, Just Master) -> m
+ _ -> M.insert domain conf m
-getNamedConf :: Propellor (S.Set NamedConf)
+getNamedConf :: Propellor (M.Map Domain NamedConf)
getNamedConf = asks _namedconf
sshPubKey :: String -> Property