secondaryFor
This commit is contained in:
parent
f10c4d4aff
commit
f4c0df84ee
|
@ -2,6 +2,7 @@ module Propellor.Property.Dns (
|
||||||
module Propellor.Types.Dns,
|
module Propellor.Types.Dns,
|
||||||
primary,
|
primary,
|
||||||
secondary,
|
secondary,
|
||||||
|
secondaryFor,
|
||||||
mkSOA,
|
mkSOA,
|
||||||
rootAddressesFrom,
|
rootAddressesFrom,
|
||||||
writeZoneFile,
|
writeZoneFile,
|
||||||
|
@ -71,10 +72,23 @@ primary hosts domain soa rs = withwarnings (check needupdate baseprop)
|
||||||
|
|
||||||
-- | Secondary dns server for a domain.
|
-- | Secondary dns server for a domain.
|
||||||
--
|
--
|
||||||
|
-- The primary server is determined by looking at the properties of other
|
||||||
|
-- hosts to find which one is configured as the primary.
|
||||||
|
--
|
||||||
-- Note that if a host is declared to be a primary and a secondary dns
|
-- Note that if a host is declared to be a primary and a secondary dns
|
||||||
-- server for the same domain, the primary server config always wins.
|
-- server for the same domain, the primary server config always wins.
|
||||||
secondary :: [Host] -> Domain -> HostName -> Property
|
secondary :: [Host] -> Domain -> Property
|
||||||
secondary hosts domain master = pureAttrProperty desc (addNamedConf conf)
|
secondary hosts domain = secondaryFor masters hosts domain
|
||||||
|
where
|
||||||
|
masters = M.keys $ M.filter ismaster $ hostAttrMap hosts
|
||||||
|
ismaster attr = case M.lookup domain (_namedconf attr) of
|
||||||
|
Nothing -> False
|
||||||
|
Just conf -> confType conf == Master && confDomain conf == domain
|
||||||
|
|
||||||
|
-- | This variant is useful if the primary server does not have its DNS
|
||||||
|
-- configured via propellor.
|
||||||
|
secondaryFor :: [HostName] -> [Host] -> Domain -> -> Property
|
||||||
|
secondaryFor masters hosts domain = pureAttrProperty desc (addNamedConf conf)
|
||||||
`requires` servingZones
|
`requires` servingZones
|
||||||
where
|
where
|
||||||
desc = "dns secondary for " ++ domain
|
desc = "dns secondary for " ++ domain
|
||||||
|
@ -82,7 +96,7 @@ secondary hosts domain master = pureAttrProperty desc (addNamedConf conf)
|
||||||
{ confDomain = domain
|
{ confDomain = domain
|
||||||
, confType = Secondary
|
, confType = Secondary
|
||||||
, confFile = "db." ++ domain
|
, confFile = "db." ++ domain
|
||||||
, confMasters = hostAddresses master hosts
|
, confMasters = concatMap (\m -> hostAddresses m hosts) masters
|
||||||
, confLines = ["allow-transfer { }"]
|
, confLines = ["allow-transfer { }"]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -246,15 +246,15 @@ cleanCloudAtCost = propertyList "cloudatcost cleanup"
|
||||||
|
|
||||||
myDnsSecondary :: Property
|
myDnsSecondary :: Property
|
||||||
myDnsSecondary = propertyList "dns secondary for all my domains"
|
myDnsSecondary = propertyList "dns secondary for all my domains"
|
||||||
[ Dns.secondary hosts "kitenet.net" master
|
[ Dns.secondaryFor wren hosts "kitenet.net"
|
||||||
, Dns.secondary hosts "joeyh.name" master
|
, Dns.secondaryFor wren hosts "joeyh.name"
|
||||||
, Dns.secondary hosts "ikiwiki.info" master
|
, Dns.secondaryFor wren hosts "ikiwiki.info"
|
||||||
, Dns.secondary hosts "olduse.net" master
|
, Dns.secondary hosts "olduse.net"
|
||||||
, Dns.secondary hosts "branchable.com" branchablemaster
|
, Dns.secondaryFor branchable hosts "branchable.com"
|
||||||
]
|
]
|
||||||
where
|
where
|
||||||
master = "wren.kitenet.net"
|
wren = ["wren.kitenet.net"]
|
||||||
branchablemaster = "branchable.com"
|
branchable = ["branchable.com"]
|
||||||
|
|
||||||
main :: IO ()
|
main :: IO ()
|
||||||
main = defaultMain hosts
|
main = defaultMain hosts
|
||||||
|
|
Loading…
Reference in New Issue