From 2793b4be94890f4b64f37c695495ff9e4ba0d5d2 Mon Sep 17 00:00:00 2001 From: Félix Sipma Date: Sun, 1 Apr 2018 22:24:17 +0200 Subject: Unbound: handle SRV record --- src/Propellor/Property/Unbound.hs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Propellor/Property/Unbound.hs b/src/Propellor/Property/Unbound.hs index 470aad7e..e6b6ca88 100644 --- a/src/Propellor/Property/Unbound.hs +++ b/src/Propellor/Property/Unbound.hs @@ -120,7 +120,15 @@ genRecord dom (PTR revip) = Just $ genPTR dom revip genRecord _ (CNAME _) = Nothing genRecord _ (NS _) = Nothing genRecord _ (TXT _) = Nothing -genRecord _ (SRV _ _ _ _) = Nothing +genRecord dom (SRV priority weight port target) = Just $ unwords + [ dValue dom + , "IN" + , "SRV" + , val priority + , val weight + , val port + , dValue target + ] genRecord _ (SSHFP _ _ _) = Nothing genRecord _ (INCLUDE _) = Nothing -- cgit v1.3-2-g0d8e From 02dcc859457e48686f0d5159375cbe8ef249d4c0 Mon Sep 17 00:00:00 2001 From: Félix Sipma Date: Sun, 1 Apr 2018 22:29:14 +0200 Subject: Unbound: simplify existing records --- src/Propellor/Property/Unbound.hs | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/src/Propellor/Property/Unbound.hs b/src/Propellor/Property/Unbound.hs index e6b6ca88..0d057924 100644 --- a/src/Propellor/Property/Unbound.hs +++ b/src/Propellor/Property/Unbound.hs @@ -115,8 +115,17 @@ genRecord' dom r = " local-data: \"" ++ fromMaybe "" (genRecord dom r) ++ "\" genRecord :: BindDomain -> Record -> Maybe String genRecord dom (Address addr) = Just $ genAddressNoTtl dom addr -genRecord dom (MX priority dest) = Just $ genMX dom priority dest -genRecord dom (PTR revip) = Just $ genPTR dom revip +genRecord dom (MX priority dest) = Just $ unwords + [ dValue dom + , "MX" + , val priority + , dValue dest + ] +genRecord dom (PTR revip) = Just $ unwords + [ revip ++ "." + , "PTR" + , dValue dom + ] genRecord _ (CNAME _) = Nothing genRecord _ (NS _) = Nothing genRecord _ (TXT _) = Nothing @@ -141,10 +150,10 @@ genAddress dom ttl addr = case addr of IPv6 _ -> genAddress' "AAAA" dom ttl addr genAddress' :: String -> BindDomain -> Maybe Int -> IPAddr -> String -genAddress' recordtype dom ttl addr = dValue dom ++ " " ++ maybe "" (\ttl' -> val ttl' ++ " ") ttl ++ "IN " ++ recordtype ++ " " ++ val addr - -genMX :: BindDomain -> Int -> BindDomain -> String -genMX dom priority dest = dValue dom ++ " " ++ "MX" ++ " " ++ val priority ++ " " ++ dValue dest - -genPTR :: BindDomain -> ReverseIP -> String -genPTR dom revip = revip ++ ". " ++ "PTR" ++ " " ++ dValue dom +genAddress' recordtype dom ttl addr = unwords $ + [ dValue dom ] + ++ maybe [] (\ttl' -> [val ttl']) ttl ++ + [ "IN" + , recordtype + , val addr + ] -- cgit v1.3-2-g0d8e From 0f022f07523a2221d527c705caff2a2d8cc83a03 Mon Sep 17 00:00:00 2001 From: Félix Sipma Date: Sun, 1 Apr 2018 22:43:20 +0200 Subject: Unbound: handle missing records --- src/Propellor/Property/Unbound.hs | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/src/Propellor/Property/Unbound.hs b/src/Propellor/Property/Unbound.hs index 0d057924..a17e5dd4 100644 --- a/src/Propellor/Property/Unbound.hs +++ b/src/Propellor/Property/Unbound.hs @@ -126,19 +126,36 @@ genRecord dom (PTR revip) = Just $ unwords , "PTR" , dValue dom ] -genRecord _ (CNAME _) = Nothing -genRecord _ (NS _) = Nothing -genRecord _ (TXT _) = Nothing +genRecord dom (CNAME dest) = Just $ unwords + [ dValue dom + , "CNAME" + , dValue dest + ] +genRecord dom (NS serv) = Just $ unwords + [ dValue dom + , "NS" + , dValue serv + ] +genRecord dom (TXT txt) = Just $ unwords + [ dValue dom + , "TXT" + , txt + ] genRecord dom (SRV priority weight port target) = Just $ unwords [ dValue dom - , "IN" , "SRV" , val priority , val weight , val port , dValue target ] -genRecord _ (SSHFP _ _ _) = Nothing +genRecord dom (SSHFP algo hash fingerprint) = Just $ unwords + [ dValue dom + , "SSHFP" + , val algo + , val hash + , fingerprint + ] genRecord _ (INCLUDE _) = Nothing genAddressNoTtl :: BindDomain -> IPAddr -> String -- cgit v1.3-2-g0d8e From 6bcb3b886ca50fc5d1cf248db3c06da8988c839c Mon Sep 17 00:00:00 2001 From: Félix Sipma Date: Fri, 4 May 2018 15:18:29 +0200 Subject: Unbound: add a warning note for CNAME --- src/Propellor/Property/Unbound.hs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Propellor/Property/Unbound.hs b/src/Propellor/Property/Unbound.hs index a17e5dd4..2949b8e0 100644 --- a/src/Propellor/Property/Unbound.hs +++ b/src/Propellor/Property/Unbound.hs @@ -126,6 +126,9 @@ genRecord dom (PTR revip) = Just $ unwords , "PTR" , dValue dom ] +-- | Be carefull with CNAMEs, unbound is not a primary DNS server, so it will +-- resolve these by itself. For a locally served zone, you probably want A/AAAA +-- records instead. genRecord dom (CNAME dest) = Just $ unwords [ dValue dom , "CNAME" -- cgit v1.3-2-g0d8e From 130283c92f9be4fc7d6a7a86aeb591dc05a7bf6c Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 4 May 2018 14:34:56 -0400 Subject: update --- src/Propellor/Property/SiteSpecific/JoeySites.hs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/Propellor/Property/SiteSpecific/JoeySites.hs b/src/Propellor/Property/SiteSpecific/JoeySites.hs index 9d7423d7..e3619c2a 100644 --- a/src/Propellor/Property/SiteSpecific/JoeySites.hs +++ b/src/Propellor/Property/SiteSpecific/JoeySites.hs @@ -915,7 +915,8 @@ homePowerMonitor user hosts ctx sshkey = propertyList "home power monitor" $ pro & Apache.installed & Apt.installed ["python", "python-pymodbus", "rrdtool", "rsync"] & File.ownerGroup "/var/www/html" user (userGroup user) - & Git.cloned user "git://git.kitenet.net/joey/homepower" d Nothing + & Git.cloned user "https://git.joeyh.name/git/joey/homepower.git" d Nothing + & Git.cloned user "https://git.joeyh.name/git/reactive-banana-automation.git" (d "reactive-banana-automation") Nothing & buildpoller & Systemd.enabled setupservicename `requires` setupserviceinstalled @@ -937,11 +938,21 @@ homePowerMonitor user hosts ctx sshkey = propertyList "home power monitor" $ pro d = "/var/www/html/homepower" sshkeyfile = d ".ssh/key" buildpoller = userScriptProperty (User "joey") - [ "cd " ++ d + [ "cd " ++ d "reactive-banana-automation" + , "cabal install" + , "cd " ++ d , "make" ] `assume` MadeChange - `requires` Apt.installed ["ghc", "make"] + `requires` Apt.installed + [ "ghc", "cabal-install", "make" + , "libghc-http-types-dev" + , "libghc-stm-dev" + , "libghc-aeson-dev" + , "libghc-wai-dev" + , "libghc-warp-dev" + , "libghc-reactive-banana-dev" + ] servicename = "homepower" servicefile = "/etc/systemd/system/" ++ servicename ++ ".service" serviceinstalled = servicefile `File.hasContent` @@ -953,6 +964,7 @@ homePowerMonitor user hosts ctx sshkey = propertyList "home power monitor" $ pro , "WorkingDirectory=" ++ d , "User=joey" , "Group=joey" + , "Restart=always" , "" , "[Install]" , "WantedBy=multi-user.target" -- cgit v1.3-2-g0d8e From d023707d420bff9de2463cf4910b7165e6ddc5d0 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 4 May 2018 23:28:51 -0400 Subject: propellor spin --- src/Propellor/Property/SiteSpecific/JoeySites.hs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Propellor/Property/SiteSpecific/JoeySites.hs b/src/Propellor/Property/SiteSpecific/JoeySites.hs index e3619c2a..ec4cac57 100644 --- a/src/Propellor/Property/SiteSpecific/JoeySites.hs +++ b/src/Propellor/Property/SiteSpecific/JoeySites.hs @@ -951,6 +951,7 @@ homePowerMonitor user hosts ctx sshkey = propertyList "home power monitor" $ pro , "libghc-aeson-dev" , "libghc-wai-dev" , "libghc-warp-dev" + , "libghc-http-client-dev" , "libghc-reactive-banana-dev" ] servicename = "homepower" -- cgit v1.3-2-g0d8e From 4c88d4f0dab95deac11fac4cd59f84c1cb76d377 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sat, 5 May 2018 11:32:24 -0400 Subject: propellor spin --- src/Propellor/Property/SiteSpecific/JoeySites.hs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Propellor/Property/SiteSpecific/JoeySites.hs b/src/Propellor/Property/SiteSpecific/JoeySites.hs index ec4cac57..1fc290bb 100644 --- a/src/Propellor/Property/SiteSpecific/JoeySites.hs +++ b/src/Propellor/Property/SiteSpecific/JoeySites.hs @@ -953,6 +953,7 @@ homePowerMonitor user hosts ctx sshkey = propertyList "home power monitor" $ pro , "libghc-warp-dev" , "libghc-http-client-dev" , "libghc-reactive-banana-dev" + , "libghc-hinotify-dev" ] servicename = "homepower" servicefile = "/etc/systemd/system/" ++ servicename ++ ".service" @@ -1020,7 +1021,9 @@ homeRouter = propertyList "home router" $ props , "bogus-priv" , "interface=wlan0" , "domain=kitenet.net" - , "dhcp-range=10.1.1.100,10.1.1.150,24h" + -- lease time is 30 minutes because the homepower + -- controller wants to know when clients disconnect + , "dhcp-range=10.1.1.100,10.1.1.150,30m" , "no-hosts" , "address=/honeybee.kitenet.net/10.1.1.1" , "address=/house.kitenet.net/10.1.1.1" -- cgit v1.3-2-g0d8e -- cgit v1.3-2-g0d8e From 7e67310cf3c9f5cb1ac1fd51582960883e9b1c34 Mon Sep 17 00:00:00 2001 From: Félix Sipma Date: Sat, 5 May 2018 21:45:08 +0200 Subject: Unbound: move haddock comment to cachingDnsServer --- src/Propellor/Property/Unbound.hs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Propellor/Property/Unbound.hs b/src/Propellor/Property/Unbound.hs index 2949b8e0..ec8b6d83 100644 --- a/src/Propellor/Property/Unbound.hs +++ b/src/Propellor/Property/Unbound.hs @@ -64,6 +64,10 @@ config = "/etc/unbound/unbound.conf.d/propellor.conf" -- | Provided a [UnboundSection], a [UnboundZone] and a [UnboundHost], -- cachingDnsServer ensure unbound is configured accordingly. -- +-- Be carefull with CNAMEs, unbound is not a primary DNS server, so it will +-- resolve these by itself. For a locally served zone, you probably want A/AAAA +-- records instead. +-- -- Example property: -- -- > cachingDnsServer @@ -126,9 +130,6 @@ genRecord dom (PTR revip) = Just $ unwords , "PTR" , dValue dom ] --- | Be carefull with CNAMEs, unbound is not a primary DNS server, so it will --- resolve these by itself. For a locally served zone, you probably want A/AAAA --- records instead. genRecord dom (CNAME dest) = Just $ unwords [ dValue dom , "CNAME" -- cgit v1.3-2-g0d8e From 9997a86d625b6ef91b7490a503f002d2a51d3997 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sat, 5 May 2018 21:56:21 -0400 Subject: propellor spin --- joeyconfig.hs | 2 +- src/Propellor/Property/SiteSpecific/JoeySites.hs | 43 +++++++++++++++++------- 2 files changed, 32 insertions(+), 13 deletions(-) diff --git a/joeyconfig.hs b/joeyconfig.hs index 6236c9e2..2b69d541 100644 --- a/joeyconfig.hs +++ b/joeyconfig.hs @@ -196,7 +196,7 @@ honeybee = host "honeybee.kitenet.net" $ props [ (SshEd25519, "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIS/hDYq1MAxfOBf49htym3BOYlx4Gk9SDpiHjv7u6IC") ] - & JoeySites.homePowerMonitor + & JoeySites.homePower (User "joey") hosts (Context "homepower.joeyh.name") diff --git a/src/Propellor/Property/SiteSpecific/JoeySites.hs b/src/Propellor/Property/SiteSpecific/JoeySites.hs index 1fc290bb..aa68869d 100644 --- a/src/Propellor/Property/SiteSpecific/JoeySites.hs +++ b/src/Propellor/Property/SiteSpecific/JoeySites.hs @@ -909,21 +909,23 @@ alarmClock oncalendar (User user) command = combineProperties "goodmorning timer & "/etc/systemd/logind.conf" `ConfFile.containsIniSetting` ("Login", "LidSwitchIgnoreInhibited", "no") --- My home power monitor. -homePowerMonitor :: IsContext c => User -> [Host] -> c -> (SshKeyType, Ssh.PubKeyText) -> Property (HasInfo + DebianLike) -homePowerMonitor user hosts ctx sshkey = propertyList "home power monitor" $ props +homePower :: IsContext c => User -> [Host] -> c -> (SshKeyType, Ssh.PubKeyText) -> Property (HasInfo + DebianLike) +homePower user hosts ctx sshkey = propertyList "home power" $ props & Apache.installed & Apt.installed ["python", "python-pymodbus", "rrdtool", "rsync"] & File.ownerGroup "/var/www/html" user (userGroup user) & Git.cloned user "https://git.joeyh.name/git/joey/homepower.git" d Nothing & Git.cloned user "https://git.joeyh.name/git/reactive-banana-automation.git" (d "reactive-banana-automation") Nothing - & buildpoller + & build & Systemd.enabled setupservicename `requires` setupserviceinstalled `onChange` Systemd.started setupservicename - & Systemd.enabled servicename - `requires` serviceinstalled - `onChange` Systemd.started servicename + & Systemd.enabled pollerservicename + `requires` pollerserviceinstalled + `onChange` Systemd.started pollerservicename + & Systemd.enabled controllerservicename + `requires` controllerserviceinstalled + `onChange` Systemd.started controllerservicename & User.hasGroup user (Group "dialout") & Group.exists (Group "gpio") Nothing & User.hasGroup user (Group "gpio") @@ -937,7 +939,7 @@ homePowerMonitor user hosts ctx sshkey = propertyList "home power monitor" $ pro where d = "/var/www/html/homepower" sshkeyfile = d ".ssh/key" - buildpoller = userScriptProperty (User "joey") + build = userScriptProperty (User "joey") [ "cd " ++ d "reactive-banana-automation" , "cabal install" , "cd " ++ d @@ -955,11 +957,11 @@ homePowerMonitor user hosts ctx sshkey = propertyList "home power monitor" $ pro , "libghc-reactive-banana-dev" , "libghc-hinotify-dev" ] - servicename = "homepower" - servicefile = "/etc/systemd/system/" ++ servicename ++ ".service" - serviceinstalled = servicefile `File.hasContent` + pollerservicename = "homepower" + pollerservicefile = "/etc/systemd/system/" ++ pollerservicename ++ ".service" + pollerserviceinstalled = pollerservicefile `File.hasContent` [ "[Unit]" - , "Description=home power monitor" + , "Description=home power poller" , "" , "[Service]" , "ExecStart=" ++ d ++ "/poller" @@ -970,6 +972,23 @@ homePowerMonitor user hosts ctx sshkey = propertyList "home power monitor" $ pro , "" , "[Install]" , "WantedBy=multi-user.target" + , "WantedBy=homepower-controller.target" + ] + controllerservicename = "homepower-controller" + controllerservicefile = "/etc/systemd/system/" ++ controllerservicename ++ ".service" + controllerserviceinstalled = controllerservicefile `File.hasContent` + [ "[Unit]" + , "Description=home power controller" + , "" + , "[Service]" + , "ExecStart=" ++ d ++ "/controller" + , "WorkingDirectory=" ++ d + , "User=joey" + , "Group=joey" + , "Restart=always" + , "" + , "[Install]" + , "WantedBy=multi-user.target" ] setupservicename = "homepower-setup" setupservicefile = "/etc/systemd/system/" ++ setupservicename ++ ".service" -- cgit v1.3-2-g0d8e From f7886b2d596311593c40260d0f5bae286d655a99 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sat, 5 May 2018 23:39:35 -0400 Subject: propellor spin --- src/Propellor/Property/SiteSpecific/JoeySites.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Propellor/Property/SiteSpecific/JoeySites.hs b/src/Propellor/Property/SiteSpecific/JoeySites.hs index aa68869d..1ce8204b 100644 --- a/src/Propellor/Property/SiteSpecific/JoeySites.hs +++ b/src/Propellor/Property/SiteSpecific/JoeySites.hs @@ -1040,9 +1040,9 @@ homeRouter = propertyList "home router" $ props , "bogus-priv" , "interface=wlan0" , "domain=kitenet.net" - -- lease time is 30 minutes because the homepower + -- lease time is short because the homepower -- controller wants to know when clients disconnect - , "dhcp-range=10.1.1.100,10.1.1.150,30m" + , "dhcp-range=10.1.1.100,10.1.1.150,5m" , "no-hosts" , "address=/honeybee.kitenet.net/10.1.1.1" , "address=/house.kitenet.net/10.1.1.1" -- cgit v1.3-2-g0d8e From 44eac317e72df5c2b433527800a00315659a9d4f Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sun, 6 May 2018 03:04:45 -0400 Subject: remove rsyslog from honeybee to save disk space --- joeyconfig.hs | 1 + 1 file changed, 1 insertion(+) diff --git a/joeyconfig.hs b/joeyconfig.hs index 2b69d541..ce4ddbee 100644 --- a/joeyconfig.hs +++ b/joeyconfig.hs @@ -176,6 +176,7 @@ honeybee :: Host honeybee = host "honeybee.kitenet.net" $ props & standardSystem Testing ARMHF [ "Home router and arm git-annex build box." ] + & Apt.removed ["rsyslog"] & cubietech_Cubietruck & hasPartition -- cgit v1.3-2-g0d8e From 9863be7663b7954452d995956ebe1d4b65edaf56 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sun, 6 May 2018 11:05:31 -0400 Subject: setting up joeyconfig after merge --- config.hs | 2 +- privdata/relocate | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 privdata/relocate diff --git a/config.hs b/config.hs index ec313725..97d90636 120000 --- a/config.hs +++ b/config.hs @@ -1 +1 @@ -config-simple.hs \ No newline at end of file +joeyconfig.hs \ No newline at end of file diff --git a/privdata/relocate b/privdata/relocate new file mode 100644 index 00000000..271692d8 --- /dev/null +++ b/privdata/relocate @@ -0,0 +1 @@ +.joeyconfig -- cgit v1.3-2-g0d8e