From 2279979d32b252d826c23288bb90a723d6a1147d Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sat, 19 Apr 2014 10:47:38 -0400 Subject: Removed root domain records from SOA. Instead, use RootDomain when calling Dns.primary. --- config-joey.hs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'config-joey.hs') diff --git a/config-joey.hs b/config-joey.hs index 1bda9dd2..e0973f94 100644 --- a/config-joey.hs +++ b/config-joey.hs @@ -124,15 +124,14 @@ hosts = -- (o) ` & myDnsSecondary & Dns.primary hosts "olduse.net" - ( Dns.mkSOA "ns1.kitenet.net" 100 - [ NS (AbsDomain "ns1.kitenet.net") - , NS (AbsDomain "ns6.gandi.net") - , NS (AbsDomain "ns2.kitenet.net") - , MX 0 (AbsDomain "kitenet.net") - , TXT "v=spf1 a -all" - ] - ) - [ (RelDomain "article", CNAME $ AbsDomain "virgil.koldfront.dk") ] + (Dns.mkSOA "ns1.kitenet.net" 100) + [ (RootDomain, NS $ AbsDomain "ns1.kitenet.net") + , (RootDomain, NS $ AbsDomain "ns6.gandi.net") + , (RootDomain, NS $ AbsDomain "ns2.kitenet.net") + , (RootDomain, MX 0 $ AbsDomain "kitenet.net") + , (RootDomain, TXT "v=spf1 a -all") + , (RelDomain "article", CNAME $ AbsDomain "virgil.koldfront.dk") + ] & Apt.installed ["ntop"] -- cgit v1.2.3 From fffa3e003a993f889831a7e897259c20d974ef75 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sat, 19 Apr 2014 11:00:48 -0400 Subject: Dns primary and secondary properties are now revertable. --- Propellor/Property/Dns.hs | 46 +++++++++++++++++++++++++++++++--------------- config-joey.hs | 2 +- debian/changelog | 1 + 3 files changed, 33 insertions(+), 16 deletions(-) (limited to 'config-joey.hs') diff --git a/Propellor/Property/Dns.hs b/Propellor/Property/Dns.hs index b9738e41..0cf2e13e 100644 --- a/Propellor/Property/Dns.hs +++ b/Propellor/Property/Dns.hs @@ -39,11 +39,18 @@ import Data.List -- The [(BindDomain, Record)] list can be used for additional records -- that cannot be configured elsewhere. For example, it might contain -- CNAMEs pointing at hosts that propellor does not control. -primary :: [Host] -> Domain -> SOA -> [(BindDomain, Record)] -> Property -primary hosts domain soa rs = withwarnings (check needupdate baseprop) - `requires` servingZones - `onChange` Service.reloaded "bind9" +primary :: [Host] -> Domain -> SOA -> [(BindDomain, Record)] -> RevertableProperty +primary hosts domain soa rs = RevertableProperty setup cleanup where + setup = withwarnings (check needupdate baseprop) + `requires` servingZones + `onChange` Service.reloaded "bind9" + cleanup = check (doesFileExist zonefile) $ + property ("removed dns primary for " ++ domain) + (makeChange $ removeZoneFile zonefile) + `requires` namedConfWritten + `onChange` Service.reloaded "bind9" + (partialzone, warnings) = genZone hosts domain soa zone = partialzone { zHosts = zHosts partialzone ++ rs } zonefile = "/etc/bind/propellor/db." ++ domain @@ -77,7 +84,7 @@ primary hosts domain soa rs = withwarnings (check needupdate baseprop) -- -- 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. -secondary :: [Host] -> Domain -> Property +secondary :: [Host] -> Domain -> RevertableProperty secondary hosts domain = secondaryFor masters hosts domain where masters = M.keys $ M.filter ismaster $ hostAttrMap hosts @@ -87,10 +94,13 @@ secondary hosts domain = secondaryFor masters hosts 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 +secondaryFor :: [HostName] -> [Host] -> Domain -> RevertableProperty +secondaryFor masters hosts domain = RevertableProperty setup cleanup where + setup = pureAttrProperty desc (addNamedConf conf) + `requires` servingZones + cleanup = namedConfWritten + desc = "dns secondary for " ++ domain conf = NamedConf { confDomain = domain @@ -104,15 +114,16 @@ secondaryFor masters hosts domain = pureAttrProperty desc (addNamedConf conf) -- configured by `primary` and `secondary`, and ensures that bind9 is -- running. servingZones :: Property -servingZones = property "serving configured dns zones" go +servingZones = namedConfWritten `requires` Apt.serviceInstalledRunning "bind9" `onChange` Service.reloaded "bind9" - where - go = do - zs <- getNamedConf - ensureProperty $ - hasContent namedConfFile $ - concatMap confStanza $ M.elems zs + +namedConfWritten :: Property +namedConfWritten = property "named.conf configured" $ do + zs <- getNamedConf + ensureProperty $ + hasContent namedConfFile $ + concatMap confStanza $ M.elems zs confStanza :: NamedConf -> [Line] confStanza c = @@ -223,6 +234,11 @@ writeZoneFile z f = do writeFile f (genZoneFile z') writeZonePropellorFile f z' +removeZoneFile :: FilePath -> IO () +removeZoneFile f = do + nukeFile f + nukeFile (zonePropellorFile f) + -- | Next to the zone file, is a ".propellor" file, which contains -- the serialized Zone. This saves the bother of parsing -- the horrible bind zone file format. diff --git a/config-joey.hs b/config-joey.hs index e0973f94..1f1b6c1f 100644 --- a/config-joey.hs +++ b/config-joey.hs @@ -245,7 +245,7 @@ cleanCloudAtCost = propertyList "cloudatcost cleanup" ] myDnsSecondary :: Property -myDnsSecondary = propertyList "dns secondary for all my domains" +myDnsSecondary = propertyList "dns secondary for all my domains" $ map toProp [ Dns.secondaryFor wren hosts "kitenet.net" , Dns.secondaryFor wren hosts "joeyh.name" , Dns.secondaryFor wren hosts "ikiwiki.info" diff --git a/debian/changelog b/debian/changelog index e84c3213..8f1e5f55 100644 --- a/debian/changelog +++ b/debian/changelog @@ -2,6 +2,7 @@ propellor (0.5.0) UNRELEASED; urgency=medium * Removed root domain records from SOA. Instead, use RootDomain when calling Dns.primary. + * Dns primary and secondary properties are now revertable. -- Joey Hess Sat, 19 Apr 2014 10:46:35 -0400 -- cgit v1.2.3 From a381b58d61867a1c02d8476df19014e450d57ea8 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sat, 19 Apr 2014 11:06:28 -0400 Subject: propellor spin --- Propellor/Attr.hs | 2 +- config-joey.hs | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'config-joey.hs') diff --git a/Propellor/Attr.hs b/Propellor/Attr.hs index 05ea3ff5..acaf28db 100644 --- a/Propellor/Attr.hs +++ b/Propellor/Attr.hs @@ -43,7 +43,7 @@ ipv6 addr = pureAttrProperty ("ipv6 " ++ addr) -- | Indicates another name for the host in the DNS. alias :: Domain -> Property -alias domain = pureAttrProperty ("aka " ++ domain) +alias domain = pureAttrProperty ("alias " ++ domain) (addDNS $ CNAME $ AbsDomain domain) addDNS :: Record -> SetAttr diff --git a/config-joey.hs b/config-joey.hs index 1f1b6c1f..d67e3aef 100644 --- a/config-joey.hs +++ b/config-joey.hs @@ -46,6 +46,7 @@ hosts = -- (o) ` & Network.ipv6to4 & Tor.isBridge & Postfix.satellite + & myDnsSecondary & Docker.configured & alias "shell.olduse.net" -- cgit v1.2.3 From 7273d18461ce548f5ca30bfd797633eafe4e0a0b Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sat, 19 Apr 2014 11:23:09 -0400 Subject: propellor spin --- config-joey.hs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'config-joey.hs') diff --git a/config-joey.hs b/config-joey.hs index d67e3aef..2f33aa31 100644 --- a/config-joey.hs +++ b/config-joey.hs @@ -23,6 +23,9 @@ import qualified Propellor.Property.SiteSpecific.GitHome as GitHome import qualified Propellor.Property.SiteSpecific.GitAnnexBuilder as GitAnnexBuilder import qualified Propellor.Property.SiteSpecific.JoeySites as JoeySites +main :: IO () +main = defaultMain hosts + -- _ ______`| ,-.__ {- Propellor -- / \___-=O`/|O`/__| (____.' @@ -46,7 +49,6 @@ hosts = -- (o) ` & Network.ipv6to4 & Tor.isBridge & Postfix.satellite - & myDnsSecondary & Docker.configured & alias "shell.olduse.net" @@ -62,6 +64,9 @@ hosts = -- (o) ` -- I'd rather this were on diatom, but it needs unstable. & alias "kgb.kitenet.net" & JoeySites.kgbServer + + & alias "ns9.kitenet.net" + & myDnsSecondary & Docker.garbageCollected `period` Daily & Apt.installed ["git-annex", "mtr", "screen"] @@ -123,12 +128,13 @@ hosts = -- (o) ` & alias "resources.olduse.net" & JoeySites.oldUseNetServer hosts + & alias "ns2.kitenet.net" & myDnsSecondary & Dns.primary hosts "olduse.net" (Dns.mkSOA "ns1.kitenet.net" 100) - [ (RootDomain, NS $ AbsDomain "ns1.kitenet.net") + [ (RootDomain, NS $ AbsDomain "ns2.kitenet.net") , (RootDomain, NS $ AbsDomain "ns6.gandi.net") - , (RootDomain, NS $ AbsDomain "ns2.kitenet.net") + , (RootDomain, NS $ AbsDomain "ns9.kitenet.net") , (RootDomain, MX 0 $ AbsDomain "kitenet.net") , (RootDomain, TXT "v=spf1 a -all") , (RelDomain "article", CNAME $ AbsDomain "virgil.koldfront.dk") @@ -257,9 +263,6 @@ myDnsSecondary = propertyList "dns secondary for all my domains" $ map toProp wren = ["wren.kitenet.net"] branchable = ["branchable.com"] -main :: IO () -main = defaultMain hosts - -- o @@ -287,6 +290,8 @@ monsters = -- but do want to track their public keys etc. & ipv4 "80.68.85.49" & ipv6 "2001:41c8:125:49::10" & alias "kite.kitenet.net" + & alias "kitenet.net" + & alias "ns1.kitenet.net" , host "branchable.com" & ipv4 "66.228.46.55" & ipv6 "2600:3c03::f03c:91ff:fedf:c0e5" -- cgit v1.2.3 From 2d175089e0f19973a03d3975e3e5c09ea7ea8631 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sat, 19 Apr 2014 11:30:33 -0400 Subject: propellor spin --- config-joey.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'config-joey.hs') diff --git a/config-joey.hs b/config-joey.hs index 2f33aa31..dd848646 100644 --- a/config-joey.hs +++ b/config-joey.hs @@ -131,7 +131,7 @@ hosts = -- (o) ` & alias "ns2.kitenet.net" & myDnsSecondary & Dns.primary hosts "olduse.net" - (Dns.mkSOA "ns1.kitenet.net" 100) + (Dns.mkSOA "ns2.kitenet.net" 100) [ (RootDomain, NS $ AbsDomain "ns2.kitenet.net") , (RootDomain, NS $ AbsDomain "ns6.gandi.net") , (RootDomain, NS $ AbsDomain "ns9.kitenet.net") -- cgit v1.2.3