summaryrefslogtreecommitdiff
path: root/Propellor/Property
diff options
context:
space:
mode:
authorJoey Hess2014-04-13 14:36:19 -0400
committerJoey Hess2014-04-13 14:36:19 -0400
commit96f07ef513f6447baec8f66d52d4490ef627a588 (patch)
tree4594e3e99794fbe8d425b20445f71f6c9a10d9e4 /Propellor/Property
parent5c75e5ec6c6edbe1a221cdcd759fbc650e74f6f1 (diff)
propellor spin
Diffstat (limited to 'Propellor/Property')
-rw-r--r--Propellor/Property/Apache.hs32
-rw-r--r--Propellor/Property/Git.hs3
-rw-r--r--Propellor/Property/SiteSpecific/JoeySites.hs1
3 files changed, 30 insertions, 6 deletions
diff --git a/Propellor/Property/Apache.hs b/Propellor/Property/Apache.hs
index 5e32b0da..81daf9e7 100644
--- a/Propellor/Property/Apache.hs
+++ b/Propellor/Property/Apache.hs
@@ -3,17 +3,21 @@ module Propellor.Property.Apache where
import Propellor
import qualified Propellor.Property.File as File
import qualified Propellor.Property.Apt as Apt
+import qualified Propellor.Property.Service as Service
type ConfigFile = [String]
siteEnabled :: HostName -> ConfigFile -> RevertableProperty
siteEnabled hn cf = RevertableProperty enable disable
where
- enable = siteAvailable hn cf
- `onChange` cmdProperty "a2ensite" ["--quiet", hn]
- `requires` Apt.installed ["apache2"]
+ enable = cmdProperty "a2ensite" ["--quiet", hn]
+ `requires` siteAvailable hn cf
+ `requires` installed
+ `onChange` reloaded
disable = 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)
@@ -21,8 +25,24 @@ siteAvailable hn cf = siteCfg hn `File.hasContent` (comment:cf)
where
comment = "# deployed with propellor, do not modify"
+modEnabled :: String -> RevertableProperty
+modEnabled modname = RevertableProperty enable disable
+ where
+ enable = cmdProperty "a2enmod" ["--quiet", modname]
+ `requires` installed
+ `onChange` reloaded
+ disable = cmdProperty "a2dismod" ["--quiet", modname]
+ `requires` installed
+ `onChange` reloaded
+
siteCfg :: HostName -> FilePath
-siteCfg hn = "/etc/apache2/sites-available/" ++ hn ++ ".conf"
+siteCfg hn = "/etc/apache2/sites-available/" ++ hn
+
+installed :: Property
+installed = Apt.installed ["apache2"]
+
+restarted :: Property
+restarted = cmdProperty "service" ["apache2", "restart"]
-restart :: Property
-restart = cmdProperty "service" ["apache2", "restart"]
+reloaded :: Property
+reloaded = Service.reloaded "apache2"
diff --git a/Propellor/Property/Git.hs b/Propellor/Property/Git.hs
index b2a53800..1dae94bf 100644
--- a/Propellor/Property/Git.hs
+++ b/Propellor/Property/Git.hs
@@ -80,6 +80,9 @@ cloned owner url dir mbranch = check originurl (Property desc checkout)
removeDirectoryRecursive dir
createDirectoryIfMissing True (takeDirectory dir)
ensureProperty $ userScriptProperty owner $ catMaybes
+ -- The </dev/null fixes an intermittent
+ -- "fatal: read error: Bad file descriptor"
+ -- when run across ssh with propellor --spin
[ Just $ "git clone " ++ shellEscape url ++ " " ++ shellEscape dir ++ " < /dev/null"
, Just $ "cd " ++ shellEscape dir
, ("git checkout " ++) <$> mbranch
diff --git a/Propellor/Property/SiteSpecific/JoeySites.hs b/Propellor/Property/SiteSpecific/JoeySites.hs
index 907233bd..4b98fe0b 100644
--- a/Propellor/Property/SiteSpecific/JoeySites.hs
+++ b/Propellor/Property/SiteSpecific/JoeySites.hs
@@ -57,6 +57,7 @@ gitServer hosts = propertyList "git.kitenet.net setup"
, Git.cloned "root" "/srv/git/joey/git.kitenet.net.git" "/srv/web/git.kitenet.net" Nothing
, website "git.kitenet.net"
, website "git.joeyh.name"
+ , toProp $ Apache.modEnabled "cgi"
-- ssh keys for branchable and github repo hooks
-- TODO: upgrade to newer git-annex-shell for notification
]