From 3dbb44a787ebc0f26de1e045fbabe9b10eeadcf8 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 31 Oct 2014 11:13:32 -0400 Subject: [PATCH 1/6] propellor spin From 5a6ff0b0f35831e3c8258f5a3407c97089e715ed Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 31 Oct 2014 12:39:45 -0400 Subject: [PATCH 2/6] update --- doc/coding_style.mdwn | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/doc/coding_style.mdwn b/doc/coding_style.mdwn index 1b6c525..10b9832 100644 --- a/doc/coding_style.mdwn +++ b/doc/coding_style.mdwn @@ -70,6 +70,14 @@ that line up with the open and close punctuation. , address = "baz" } +Similarly, data structures line up the leading `=` with the following `|` + + data Foo + = Bar + | Baz + | Quux Foo + deriving (Eq, Ord) + Module imports are separated into two blocks, one for third-party modules, and one for modules that are part of propellor. (Additional blocks can be used if it makes sense.) From 784210a57398c37d7517ef4636696139c0ec99ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Sipma?= Date: Fri, 31 Oct 2014 20:13:37 +0100 Subject: [PATCH 3/6] Propellor.Property.Nginx: use System.Posix.Files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bug: the "onChange reloaded" in siteEnabled does not seem to be fired... Does it works in Propellor.Property.Apache.siteEnabled? Signed-off-by: Félix Sipma --- src/Propellor/Property/Nginx.hs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/Propellor/Property/Nginx.hs b/src/Propellor/Property/Nginx.hs index 97792fc..397570d 100644 --- a/src/Propellor/Property/Nginx.hs +++ b/src/Propellor/Property/Nginx.hs @@ -4,21 +4,26 @@ import Propellor import qualified Propellor.Property.File as File import qualified Propellor.Property.Apt as Apt import qualified Propellor.Property.Service as Service +import System.Posix.Files type ConfigFile = [String] siteEnabled :: HostName -> ConfigFile -> RevertableProperty siteEnabled hn cf = RevertableProperty enable disable where - enable = trivial (cmdProperty "ln" ["-s", siteValRelativeCfg hn, siteVal hn]) + enable = check test prop `describe` ("nginx site enabled " ++ hn) `requires` siteAvailable hn cf `requires` installed `onChange` reloaded - disable = trivial $ - ("nginx site disabled " ++ hn) ==> - File.notPresent (siteCfg hn) - `onChange` cmdProperty "rm" [siteVal hn] + where + test = not <$> doesFileExist (siteVal hn) + prop = property "nginx site in place" $ makeChange $ + createSymbolicLink target dir + target = siteValRelativeCfg hn + dir = siteVal hn + disable = trivial $ File.notPresent (siteVal hn) + `describe` ("nginx site disable" ++ hn) `requires` installed `onChange` reloaded From ef9abb9b676f80b3e079a429f55a0319f6efdb8d Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 31 Oct 2014 17:47:52 -0400 Subject: [PATCH 4/6] Apache: Fix daemon reload when enabling a new module or site. --- debian/changelog | 1 + src/Propellor/Property/Apache.hs | 36 +++++++++++++++++++------------- 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/debian/changelog b/debian/changelog index 804d54c..5b45c85 100644 --- a/debian/changelog +++ b/debian/changelog @@ -2,6 +2,7 @@ propellor (0.9.2) UNRELEASED; urgency=medium * Added nginx module, contributed by Félix Sipma. * Added firewall module, contributed by Arnaud Bailly. + * Apache: Fix daemon reload when enabling a new module or site. -- Joey Hess Thu, 30 Oct 2014 16:36:06 -0400 diff --git a/src/Propellor/Property/Apache.hs b/src/Propellor/Property/Apache.hs index 175e196..1d9c35c 100644 --- a/src/Propellor/Property/Apache.hs +++ b/src/Propellor/Property/Apache.hs @@ -4,23 +4,26 @@ import Propellor import qualified Propellor.Property.File as File import qualified Propellor.Property.Apt as Apt import qualified Propellor.Property.Service as Service +import Utility.SafeCommand type ConfigFile = [String] siteEnabled :: HostName -> ConfigFile -> RevertableProperty siteEnabled hn cf = RevertableProperty enable disable where - enable = trivial (cmdProperty "a2ensite" ["--quiet", hn]) - `describe` ("apache site enabled " ++ hn) - `requires` siteAvailable hn cf - `requires` installed - `onChange` reloaded - disable = trivial $ combineProperties + enable = check (not <$> isenabled) $ + cmdProperty "a2ensite" ["--quiet", hn] + `describe` ("apache site enabled " ++ hn) + `requires` siteAvailable hn cf + `requires` installed + `onChange` reloaded + disable = combineProperties ("apache site disabled " ++ hn) (map File.notPresent (siteCfg hn)) `onChange` cmdProperty "a2dissite" ["--quiet", hn] `requires` installed `onChange` reloaded + isenabled = boolSystem "a2query" [Param "-q", Param "-s", Param hn] siteAvailable :: HostName -> ConfigFile -> Property siteAvailable hn cf = combineProperties ("apache site available " ++ hn) $ @@ -31,17 +34,20 @@ siteAvailable hn cf = combineProperties ("apache site available " ++ hn) $ modEnabled :: String -> RevertableProperty modEnabled modname = RevertableProperty enable disable where - enable = trivial $ cmdProperty "a2enmod" ["--quiet", modname] - `describe` ("apache module enabled " ++ modname) - `requires` installed - `onChange` reloaded - disable = trivial $ cmdProperty "a2dismod" ["--quiet", modname] - `describe` ("apache module disabled " ++ modname) - `requires` installed - `onChange` reloaded + enable = check (not <$> isenabled) $ + cmdProperty "a2enmod" ["--quiet", modname] + `describe` ("apache module enabled " ++ modname) + `requires` installed + `onChange` reloaded + disable = check isenabled $ + cmdProperty "a2dismod" ["--quiet", modname] + `describe` ("apache module disabled " ++ modname) + `requires` installed + `onChange` reloaded + isenabled = boolSystem "a2query" [Param "-q", Param "-m", Param modname] -- This is a list of config files because different versions of apache --- use different filenames. Propellor simply writen them all. +-- use different filenames. Propellor simply writes them all. siteCfg :: HostName -> [FilePath] siteCfg hn = -- Debian pre-2.4 From 55430812bca0f16e43efa19139b6aea5750d17e6 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 31 Oct 2014 17:54:32 -0400 Subject: [PATCH 5/6] propellor spin --- config-joey.hs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/config-joey.hs b/config-joey.hs index 74647df..c36786b 100644 --- a/config-joey.hs +++ b/config-joey.hs @@ -50,6 +50,8 @@ darkstar :: Host darkstar = host "darkstar.kitenet.net" & ipv6 "2001:4830:1600:187::2" -- sixxs tunnel + ! Apache.siteEnabled "nntp.olduse.net" (JoeySites.apachecfg "nntp.olduse.net" False []) + & Apt.buildDep ["git-annex"] `period` Daily & Docker.configured ! Docker.docked hosts "android-git-annex" From ca3dff2566a36245fdede353a445b35aaf5765b4 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 31 Oct 2014 17:57:11 -0400 Subject: [PATCH 6/6] cleanup --- config-joey.hs | 2 -- 1 file changed, 2 deletions(-) diff --git a/config-joey.hs b/config-joey.hs index c36786b..74647df 100644 --- a/config-joey.hs +++ b/config-joey.hs @@ -50,8 +50,6 @@ darkstar :: Host darkstar = host "darkstar.kitenet.net" & ipv6 "2001:4830:1600:187::2" -- sixxs tunnel - ! Apache.siteEnabled "nntp.olduse.net" (JoeySites.apachecfg "nntp.olduse.net" False []) - & Apt.buildDep ["git-annex"] `period` Daily & Docker.configured ! Docker.docked hosts "android-git-annex"