From f10c4d4aff6810a502cfc770013046e42efc33ef Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sat, 19 Apr 2014 01:42:19 -0400 Subject: make primary dns server beat secondary if both are defined for a domain Made my config file simpler.. --- Propellor/Attr.hs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'Propellor/Attr.hs') 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 -- cgit v1.2.3