From 98a311476379eb8c05a7a720799cd3416091bbe7 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 22 Jul 2014 15:25:07 -0400 Subject: propellor spin --- src/Propellor/Property/Apache.hs | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'src/Propellor/Property/Apache.hs') diff --git a/src/Propellor/Property/Apache.hs b/src/Propellor/Property/Apache.hs index cf3e62cc..b1fa9d9a 100644 --- a/src/Propellor/Property/Apache.hs +++ b/src/Propellor/Property/Apache.hs @@ -15,15 +15,16 @@ siteEnabled hn cf = RevertableProperty enable disable `requires` siteAvailable hn cf `requires` installed `onChange` reloaded - disable = trivial $ File.notPresent (siteCfg hn) - `describe` ("apache site disabled " ++ hn) + disable = trivial $ combineProperties + ("apache site disabled " ++ hn) + (map File.notPresent (siteCfg hn)) `onChange` cmdProperty "a2dissite" ["--quiet", hn] `requires` installed `onChange` reloaded siteAvailable :: HostName -> ConfigFile -> Property -siteAvailable hn cf = siteCfg hn `File.hasContent` (comment:cf) - `describe` ("apache site available " ++ hn) +siteAvailable hn cf = combineProperties ("apache site available " ++ hn) $ + map (`File.hasContent` (comment:cf)) (siteCfg hn) where comment = "# deployed with propellor, do not modify" @@ -39,8 +40,15 @@ modEnabled modname = RevertableProperty enable disable `requires` installed `onChange` reloaded -siteCfg :: HostName -> FilePath -siteCfg hn = "/etc/apache2/sites-available/" ++ hn +-- This is a list of config files because different versions of apache +-- use different filenames. Propellor simply writen them all. +siteCfg :: HostName -> [FilePath] +siteCfg hn = + -- Debian pre-2.4 + [ "/etc/apache2/sites-available/" ++ hn + -- Debian 2.4+ + , "/etc/apache2/sites-available/" ++ hn ++ ".conf" + ] installed :: Property installed = Apt.installed ["apache2"] -- cgit v1.3-2-g0d8e From dc1a8db06455a287169f765b4e5c115200386359 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 22 Jul 2014 16:28:04 -0400 Subject: propellor spin --- src/Propellor/Property/Apache.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Propellor/Property/Apache.hs') diff --git a/src/Propellor/Property/Apache.hs b/src/Propellor/Property/Apache.hs index b1fa9d9a..e2ee0346 100644 --- a/src/Propellor/Property/Apache.hs +++ b/src/Propellor/Property/Apache.hs @@ -10,7 +10,7 @@ type ConfigFile = [String] siteEnabled :: HostName -> ConfigFile -> RevertableProperty siteEnabled hn cf = RevertableProperty enable disable where - enable = trivial $ cmdProperty "a2ensite" ["--quiet", hn] + enable = cmdProperty "a2ensite" ["--quiet", hn] `describe` ("apache site enabled " ++ hn) `requires` siteAvailable hn cf `requires` installed -- cgit v1.3-2-g0d8e From ed8396646039c68eeb7aec7788258205fd998a5f Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 22 Jul 2014 16:29:22 -0400 Subject: propellor spin --- src/Propellor/Property/Apache.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Propellor/Property/Apache.hs') diff --git a/src/Propellor/Property/Apache.hs b/src/Propellor/Property/Apache.hs index e2ee0346..a8014999 100644 --- a/src/Propellor/Property/Apache.hs +++ b/src/Propellor/Property/Apache.hs @@ -10,7 +10,7 @@ type ConfigFile = [String] siteEnabled :: HostName -> ConfigFile -> RevertableProperty siteEnabled hn cf = RevertableProperty enable disable where - enable = cmdProperty "a2ensite" ["--quiet", hn] + enable = trivial (cmdProperty "a2ensite" ["--quiet", hn]) `describe` ("apache site enabled " ++ hn) `requires` siteAvailable hn cf `requires` installed -- cgit v1.3-2-g0d8e From 660f77c28fe11534139e8d9ecda2d573921fa8dd Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 22 Jul 2014 16:40:11 -0400 Subject: propellor spin --- src/Propellor/Property/Apache.hs | 16 ++++++++++++++ src/Propellor/Property/SiteSpecific/JoeySites.hs | 27 ++++++++---------------- 2 files changed, 25 insertions(+), 18 deletions(-) (limited to 'src/Propellor/Property/Apache.hs') diff --git a/src/Propellor/Property/Apache.hs b/src/Propellor/Property/Apache.hs index a8014999..e6930893 100644 --- a/src/Propellor/Property/Apache.hs +++ b/src/Propellor/Property/Apache.hs @@ -68,3 +68,19 @@ multiSSL = "/etc/apache2/conf.d/ssl" `File.hasContent` ] `describe` "apache SNI enabled" `onChange` reloaded + +-- | Config file fragment that can be inserted into a +-- stanza to allow global read access to the directory. +-- +-- Works with multiple versions of apache that have different ways to do +-- it. +allowAll :: String +allowAll = unlines + [ "" + , "Order allow,deny" + , "allow from all" + , "" + , "= 2.4>" + , "Require all granted" + , "" + ] diff --git a/src/Propellor/Property/SiteSpecific/JoeySites.hs b/src/Propellor/Property/SiteSpecific/JoeySites.hs index 40e1bead..51d3d60c 100644 --- a/src/Propellor/Property/SiteSpecific/JoeySites.hs +++ b/src/Propellor/Property/SiteSpecific/JoeySites.hs @@ -61,9 +61,7 @@ oldUseNetServer hosts = propertyList ("olduse.net server") , " " , " Options Indexes FollowSymlinks" , " AllowOverride None" - -- I had this in the file before. - -- This may be needed by a newer version of apache? - --, " Require all granted" + , Apache.allowAll , " " ] ] @@ -578,9 +576,7 @@ legacyWebSites = propertyList "legacy web sites" , "" , " Options Indexes FollowSymLinks MultiViews ExecCGI Includes" , " AllowOverride None" - , " Order allow,deny" - , " allow from all" - , " Require all granted" + , Apache.allowAll , "" , "ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/" @@ -588,24 +584,19 @@ legacyWebSites = propertyList "legacy web sites" , "" , " AllowOverride None" , " Options ExecCGI" - , " Order allow,deny" - , " allow from all" + , Apache.allowAll , "" , "Alias /pipermail/ /var/lib/mailman/archives/public/" , "" , " Options Indexes MultiViews FollowSymlinks" , " AllowOverride None" - , " Order allow,deny" - , " Allow from all" - , " Require all granted" + , Apache.allowAll , "" , "Alias /images/ /usr/share/images/" , "" , " Options Indexes MultiViews" , " AllowOverride None" - , " Order allow,deny" - , " Allow from all" - , " Require all granted" + , Apache.allowAll , "" , "RewriteEngine On" @@ -672,7 +663,7 @@ legacyWebSites = propertyList "legacy web sites" , "" , " Options Indexes ExecCGI" , " AllowOverride None" - , " Require all granted" + , Apache.allowAll , "" ] , alias "sows-ear.kitenet.net" @@ -683,7 +674,7 @@ legacyWebSites = propertyList "legacy web sites" , "" , " Options FollowSymLinks" , " AllowOverride None" - , " Require all granted" + , Apache.allowAll , "" ] , alias "wortroot.kitenet.net" @@ -694,7 +685,7 @@ legacyWebSites = propertyList "legacy web sites" , "" , " Options FollowSymLinks" , " AllowOverride None" - , " Require all granted" + , Apache.allowAll , "" ] , alias "joey.kitenet.net" @@ -703,7 +694,7 @@ legacyWebSites = propertyList "legacy web sites" , "" , " Options Indexes ExecCGI" , " AllowOverride None" - , " Require all granted" + , Apache.allowAll , "" , "RewriteEngine On" -- cgit v1.3-2-g0d8e