diff options
| author | Joey Hess <joeyh@joeyh.name> | 2015-10-10 12:43:28 -0400 |
|---|---|---|
| committer | Joey Hess <joeyh@joeyh.name> | 2015-10-10 12:43:28 -0400 |
| commit | e011925ed89687df29c3a3a53a12357e8a5d42b1 (patch) | |
| tree | 56004d57a4965fe6572cedd393e4b7084ac33a7c | |
| parent | 62ad133081963d9c4b41d35c9030feaa2ae3b6fc (diff) | |
propellor spin
| -rw-r--r-- | config-joey.hs | 9 | ||||
| -rw-r--r-- | 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 + [ "<VirtualHost *:"++show p++">" + , "ServerName "++hn++":"++show p + , "DocumentRoot " ++ docroot + , "ErrorLog /var/log/apache2/error.log" + , "LogLevel warn" + , "CustomLog /var/log/apache2/access.log combined" + , "ServerSignature On" + , "</VirtualHost>" + ] + 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) $ |
