From e011925ed89687df29c3a3a53a12357e8a5d42b1 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sat, 10 Oct 2015 12:43:28 -0400 Subject: propellor spin --- config-joey.hs | 9 ++++++--- src/Propellor/Property/Apache.hs | 25 +++++++++++++++++++++---- 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/config-joey.hs b/config-joey.hs index 9e2f1fe7..3b0b9e8c 100644 --- a/config-joey.hs +++ b/config-joey.hs @@ -20,6 +20,7 @@ import qualified Propellor.Property.OpenId as OpenId import qualified Propellor.Property.Docker as Docker import qualified Propellor.Property.Git as Git import qualified Propellor.Property.Postfix as Postfix +import qualified Propellor.Property.Apache as Apache import qualified Propellor.Property.Grub as Grub import qualified Propellor.Property.Obnam as Obnam import qualified Propellor.Property.Gpg as Gpg @@ -36,7 +37,6 @@ import qualified Propellor.Property.SiteSpecific.IABak as IABak import qualified Propellor.Property.SiteSpecific.Branchable as Branchable import qualified Propellor.Property.SiteSpecific.JoeySites as JoeySites import Propellor.Property.DiskImage -import Propellor.Types.Container main :: IO () -- _ ______`| ,-.__ main = defaultMain hosts -- / \___-=O`/|O`/__| (____.' @@ -427,7 +427,7 @@ iabak = host "iabak.archiveteam.org" webserver :: Systemd.Container webserver = standardStableContainer "webserver" & Systemd.bind "/var/www" - & Apt.serviceInstalledRunning "apache2" + & Apache.installed -- My own openid provider. Uses php, so containerized for security -- and administrative sanity. @@ -442,10 +442,13 @@ openidProvider = standardStableDockerContainer "openid-provider" ancientKitenet :: Systemd.Container ancientKitenet = standardStableContainer "ancient-kitenet" & alias "ancient.kitenet.net" - & Apt.serviceInstalledRunning "apache2" + & Apache.installed + & Apache.siteDisabled "000-default" & "/etc/apache2/ports.conf" `File.hasContent` ["Listen 1994"] + `onChange` Apache.reloaded & Git.cloned (User "root") "git://kitenet-net.branchable.com/" "/var/www/html" (Just "remotes/origin/old-kitenet.net") + & Apache.virtualHost "ancient.kitenet.net" (Port 1994) "/var/www/html" oldusenetShellBox :: Systemd.Container oldusenetShellBox = standardStableContainer "oldusenet-shellbox" diff --git a/src/Propellor/Property/Apache.hs b/src/Propellor/Property/Apache.hs index fe81dcd8..49e3d525 100644 --- a/src/Propellor/Property/Apache.hs +++ b/src/Propellor/Property/Apache.hs @@ -7,6 +7,20 @@ import qualified Propellor.Property.Service as Service type ConfigFile = [String] +-- | A basic virtual host, publishing a directory, and logging to +-- the combined apache log file. +virtualHost :: HostName -> Port -> FilePath -> RevertableProperty +virtualHost hn (Port p) docroot = siteEnabled hn + [ "" + , "ServerName "++hn++":"++show p + , "DocumentRoot " ++ docroot + , "ErrorLog /var/log/apache2/error.log" + , "LogLevel warn" + , "CustomLog /var/log/apache2/access.log combined" + , "ServerSignature On" + , "" + ] + siteEnabled :: HostName -> ConfigFile -> RevertableProperty siteEnabled hn cf = enable disable where @@ -19,13 +33,16 @@ siteEnabled hn cf = enable disable `requires` installed `onChange` reloaded ] - disable = combineProperties - ("apache site disabled " ++ hn) - (map File.notPresent (siteCfg hn)) + disable = siteDisabled hn + isenabled = boolSystem "a2query" [Param "-q", Param "-s", Param hn] + +siteDisabled :: HostName -> Property NoInfo +siteDisabled hn = 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 NoInfo siteAvailable hn cf = combineProperties ("apache site available " ++ hn) $ -- cgit v1.2.3