summaryrefslogtreecommitdiff
path: root/config-simple.hs
diff options
context:
space:
mode:
authorJoey Hess2016-04-13 12:38:10 -0400
committerJoey Hess2016-04-13 12:38:10 -0400
commita6f1745879ef3af53d6bd770b1ac634cf3cd4a0a (patch)
treed791cd88084f262238e3c6cec618d9708f2d1787 /config-simple.hs
parent1ec1d3a85cee8727c427c0c49e583aa3472143b2 (diff)
propellor spin
Diffstat (limited to 'config-simple.hs')
-rw-r--r--config-simple.hs33
1 files changed, 33 insertions, 0 deletions
diff --git a/config-simple.hs b/config-simple.hs
index 42b3d838..d50dc568 100644
--- a/config-simple.hs
+++ b/config-simple.hs
@@ -7,6 +7,13 @@ import qualified Propellor.Property.Apt as Apt
import qualified Propellor.Property.Cron as Cron
import qualified Propellor.Property.User as User
+import System.FilePath
+import Propellor.Types.Core
+import qualified Propellor.Property.Chroot as Chroot
+import Propellor.Property.Chroot
+import qualified Propellor.Property.Mount as Mount
+import Control.Monad.IO.Class
+
main :: IO ()
main = defaultMain hosts
@@ -27,3 +34,29 @@ mybox = host "mybox.example.com" $ props
& User.hasSomePassword (User "root")
& File.dirExists "/var/www"
& Cron.runPropellor (Cron.Times "30 * * * *")
+
+schroot :: String -> Chroot -> RevertableProperty (HasInfo + DebianLike) DebianLike
+schroot sn chroot@(Chroot.Chroot chrootdir _ _) = (setup `requires` installed) <!> cleanup
+ where
+ setup :: Property (HasInfo + DebianLike)
+ setup = conf `requires` (provision `onChange` targz)
+ where
+ provision :: Property (HasInfo + DebianLike)
+ provision = setupRevertableProperty (Chroot.provisioned chroot) `before` umount
+ where
+ umount :: Property Linux
+ umount = property ("umount " ++ chrootdir) $ do
+ liftIO $ Mount.unmountBelow chrootdir
+ return NoChange
+ cleanup :: Property DebianLike
+ cleanup = File.notPresent (schrootChrootD </> sn)
+ `requires` File.notPresent tarball
+ `requires` revert (Chroot.provisioned chroot)
+ tarball = chrootdir <.> "tar.gz"
+ -- dummy stuff added to make it compile as I don't have the real
+ -- stuff handy.
+ installed = undefined :: Property DebianLike
+ conf = undefined :: Property DebianLike
+ targz = undefined :: Property DebianLike
+ schrootChrootD = undefined :: FilePath
+