propellor spin

This commit is contained in:
Joey Hess 2014-04-13 14:36:19 -04:00
parent 5c75e5ec6c
commit 96f07ef513
Failed to extract signature
3 changed files with 31 additions and 7 deletions

View File

@ -3,17 +3,21 @@ module Propellor.Property.Apache where
import Propellor import Propellor
import qualified Propellor.Property.File as File import qualified Propellor.Property.File as File
import qualified Propellor.Property.Apt as Apt import qualified Propellor.Property.Apt as Apt
import qualified Propellor.Property.Service as Service
type ConfigFile = [String] type ConfigFile = [String]
siteEnabled :: HostName -> ConfigFile -> RevertableProperty siteEnabled :: HostName -> ConfigFile -> RevertableProperty
siteEnabled hn cf = RevertableProperty enable disable siteEnabled hn cf = RevertableProperty enable disable
where where
enable = siteAvailable hn cf enable = cmdProperty "a2ensite" ["--quiet", hn]
`onChange` cmdProperty "a2ensite" ["--quiet", hn] `requires` siteAvailable hn cf
`requires` Apt.installed ["apache2"] `requires` installed
`onChange` reloaded
disable = File.notPresent (siteCfg hn) disable = File.notPresent (siteCfg hn)
`onChange` cmdProperty "a2dissite" ["--quiet", hn] `onChange` cmdProperty "a2dissite" ["--quiet", hn]
`requires` installed
`onChange` reloaded
siteAvailable :: HostName -> ConfigFile -> Property siteAvailable :: HostName -> ConfigFile -> Property
siteAvailable hn cf = siteCfg hn `File.hasContent` (comment:cf) siteAvailable hn cf = siteCfg hn `File.hasContent` (comment:cf)
@ -21,8 +25,24 @@ siteAvailable hn cf = siteCfg hn `File.hasContent` (comment:cf)
where where
comment = "# deployed with propellor, do not modify" comment = "# deployed with propellor, do not modify"
siteCfg :: HostName -> FilePath modEnabled :: String -> RevertableProperty
siteCfg hn = "/etc/apache2/sites-available/" ++ hn ++ ".conf" modEnabled modname = RevertableProperty enable disable
where
enable = cmdProperty "a2enmod" ["--quiet", modname]
`requires` installed
`onChange` reloaded
disable = cmdProperty "a2dismod" ["--quiet", modname]
`requires` installed
`onChange` reloaded
restart :: Property siteCfg :: HostName -> FilePath
restart = cmdProperty "service" ["apache2", "restart"] siteCfg hn = "/etc/apache2/sites-available/" ++ hn
installed :: Property
installed = Apt.installed ["apache2"]
restarted :: Property
restarted = cmdProperty "service" ["apache2", "restart"]
reloaded :: Property
reloaded = Service.reloaded "apache2"

View File

@ -80,6 +80,9 @@ cloned owner url dir mbranch = check originurl (Property desc checkout)
removeDirectoryRecursive dir removeDirectoryRecursive dir
createDirectoryIfMissing True (takeDirectory dir) createDirectoryIfMissing True (takeDirectory dir)
ensureProperty $ userScriptProperty owner $ catMaybes 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 $ "git clone " ++ shellEscape url ++ " " ++ shellEscape dir ++ " < /dev/null"
, Just $ "cd " ++ shellEscape dir , Just $ "cd " ++ shellEscape dir
, ("git checkout " ++) <$> mbranch , ("git checkout " ++) <$> mbranch

View File

@ -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 , Git.cloned "root" "/srv/git/joey/git.kitenet.net.git" "/srv/web/git.kitenet.net" Nothing
, website "git.kitenet.net" , website "git.kitenet.net"
, website "git.joeyh.name" , website "git.joeyh.name"
, toProp $ Apache.modEnabled "cgi"
-- ssh keys for branchable and github repo hooks -- ssh keys for branchable and github repo hooks
-- TODO: upgrade to newer git-annex-shell for notification -- TODO: upgrade to newer git-annex-shell for notification
] ]