Merge branch 'joeyconfig'
This commit is contained in:
commit
8526291789
|
@ -2,6 +2,7 @@ propellor (0.9.2) UNRELEASED; urgency=medium
|
||||||
|
|
||||||
* Added nginx module, contributed by Félix Sipma.
|
* Added nginx module, contributed by Félix Sipma.
|
||||||
* Added firewall module, contributed by Arnaud Bailly.
|
* Added firewall module, contributed by Arnaud Bailly.
|
||||||
|
* Apache: Fix daemon reload when enabling a new module or site.
|
||||||
|
|
||||||
-- Joey Hess <joeyh@debian.org> Thu, 30 Oct 2014 16:36:06 -0400
|
-- Joey Hess <joeyh@debian.org> Thu, 30 Oct 2014 16:36:06 -0400
|
||||||
|
|
||||||
|
|
|
@ -70,6 +70,14 @@ that line up with the open and close punctuation.
|
||||||
, address = "baz"
|
, address = "baz"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Similarly, data structures line up the leading `=` with the following `|`
|
||||||
|
|
||||||
|
data Foo
|
||||||
|
= Bar
|
||||||
|
| Baz
|
||||||
|
| Quux Foo
|
||||||
|
deriving (Eq, Ord)
|
||||||
|
|
||||||
Module imports are separated into two blocks, one for third-party modules,
|
Module imports are separated into two blocks, one for third-party modules,
|
||||||
and one for modules that are part of propellor. (Additional blocks can be used
|
and one for modules that are part of propellor. (Additional blocks can be used
|
||||||
if it makes sense.)
|
if it makes sense.)
|
||||||
|
|
|
@ -4,23 +4,26 @@ 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
|
import qualified Propellor.Property.Service as Service
|
||||||
|
import Utility.SafeCommand
|
||||||
|
|
||||||
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 = trivial (cmdProperty "a2ensite" ["--quiet", hn])
|
enable = check (not <$> isenabled) $
|
||||||
`describe` ("apache site enabled " ++ hn)
|
cmdProperty "a2ensite" ["--quiet", hn]
|
||||||
`requires` siteAvailable hn cf
|
`describe` ("apache site enabled " ++ hn)
|
||||||
`requires` installed
|
`requires` siteAvailable hn cf
|
||||||
`onChange` reloaded
|
`requires` installed
|
||||||
disable = trivial $ combineProperties
|
`onChange` reloaded
|
||||||
|
disable = combineProperties
|
||||||
("apache site disabled " ++ hn)
|
("apache site disabled " ++ hn)
|
||||||
(map File.notPresent (siteCfg hn))
|
(map File.notPresent (siteCfg hn))
|
||||||
`onChange` cmdProperty "a2dissite" ["--quiet", hn]
|
`onChange` cmdProperty "a2dissite" ["--quiet", hn]
|
||||||
`requires` installed
|
`requires` installed
|
||||||
`onChange` reloaded
|
`onChange` reloaded
|
||||||
|
isenabled = boolSystem "a2query" [Param "-q", Param "-s", Param hn]
|
||||||
|
|
||||||
siteAvailable :: HostName -> ConfigFile -> Property
|
siteAvailable :: HostName -> ConfigFile -> Property
|
||||||
siteAvailable hn cf = combineProperties ("apache site available " ++ hn) $
|
siteAvailable hn cf = combineProperties ("apache site available " ++ hn) $
|
||||||
|
@ -31,17 +34,20 @@ siteAvailable hn cf = combineProperties ("apache site available " ++ hn) $
|
||||||
modEnabled :: String -> RevertableProperty
|
modEnabled :: String -> RevertableProperty
|
||||||
modEnabled modname = RevertableProperty enable disable
|
modEnabled modname = RevertableProperty enable disable
|
||||||
where
|
where
|
||||||
enable = trivial $ cmdProperty "a2enmod" ["--quiet", modname]
|
enable = check (not <$> isenabled) $
|
||||||
`describe` ("apache module enabled " ++ modname)
|
cmdProperty "a2enmod" ["--quiet", modname]
|
||||||
`requires` installed
|
`describe` ("apache module enabled " ++ modname)
|
||||||
`onChange` reloaded
|
`requires` installed
|
||||||
disable = trivial $ cmdProperty "a2dismod" ["--quiet", modname]
|
`onChange` reloaded
|
||||||
`describe` ("apache module disabled " ++ modname)
|
disable = check isenabled $
|
||||||
`requires` installed
|
cmdProperty "a2dismod" ["--quiet", modname]
|
||||||
`onChange` reloaded
|
`describe` ("apache module disabled " ++ modname)
|
||||||
|
`requires` installed
|
||||||
|
`onChange` reloaded
|
||||||
|
isenabled = boolSystem "a2query" [Param "-q", Param "-m", Param modname]
|
||||||
|
|
||||||
-- This is a list of config files because different versions of apache
|
-- This is a list of config files because different versions of apache
|
||||||
-- use different filenames. Propellor simply writen them all.
|
-- use different filenames. Propellor simply writes them all.
|
||||||
siteCfg :: HostName -> [FilePath]
|
siteCfg :: HostName -> [FilePath]
|
||||||
siteCfg hn =
|
siteCfg hn =
|
||||||
-- Debian pre-2.4
|
-- Debian pre-2.4
|
||||||
|
|
|
@ -4,21 +4,26 @@ 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
|
import qualified Propellor.Property.Service as Service
|
||||||
|
import System.Posix.Files
|
||||||
|
|
||||||
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 = trivial (cmdProperty "ln" ["-s", siteValRelativeCfg hn, siteVal hn])
|
enable = check test prop
|
||||||
`describe` ("nginx site enabled " ++ hn)
|
`describe` ("nginx site enabled " ++ hn)
|
||||||
`requires` siteAvailable hn cf
|
`requires` siteAvailable hn cf
|
||||||
`requires` installed
|
`requires` installed
|
||||||
`onChange` reloaded
|
`onChange` reloaded
|
||||||
disable = trivial $
|
where
|
||||||
("nginx site disabled " ++ hn) ==>
|
test = not <$> doesFileExist (siteVal hn)
|
||||||
File.notPresent (siteCfg hn)
|
prop = property "nginx site in place" $ makeChange $
|
||||||
`onChange` cmdProperty "rm" [siteVal hn]
|
createSymbolicLink target dir
|
||||||
|
target = siteValRelativeCfg hn
|
||||||
|
dir = siteVal hn
|
||||||
|
disable = trivial $ File.notPresent (siteVal hn)
|
||||||
|
`describe` ("nginx site disable" ++ hn)
|
||||||
`requires` installed
|
`requires` installed
|
||||||
`onChange` reloaded
|
`onChange` reloaded
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue