summaryrefslogtreecommitdiff
path: root/src/Propellor/Property/Systemd.hs
diff options
context:
space:
mode:
authorJoey Hess2014-11-21 15:55:27 -0400
committerJoey Hess2014-11-21 15:55:27 -0400
commit9e611d87cd95999eb6b3e5e7f6c855f7c092f57c (patch)
treebea58430eeb0ab69286d95c6dd57795d46e7e04b /src/Propellor/Property/Systemd.hs
parentfbce215f3381b36df64c0e268bb816b1b0a4fd0d (diff)
add debootstrap parameters
Diffstat (limited to 'src/Propellor/Property/Systemd.hs')
-rw-r--r--src/Propellor/Property/Systemd.hs25
1 files changed, 15 insertions, 10 deletions
diff --git a/src/Propellor/Property/Systemd.hs b/src/Propellor/Property/Systemd.hs
index ce7d63c1..d91b441b 100644
--- a/src/Propellor/Property/Systemd.hs
+++ b/src/Propellor/Property/Systemd.hs
@@ -23,11 +23,11 @@ type ServiceName = String
type MachineName = String
-data Container = Container MachineName System Host
+data Container = Container MachineName Chroot.Chroot Host
instance Hostlike Container where
- (Container n s h) & p = Container n s (h & p)
- (Container n s h) &^ p = Container n s (h &^ p)
+ (Container n c h) & p = Container n c (h & p)
+ (Container n c h) &^ p = Container n c (h &^ p)
getHost (Container _ _ h) = h
-- dbus is only a Recommends of systemd, but is needed for communication
@@ -68,15 +68,19 @@ persistentJournal = check (not <$> doesDirectoryExist dir) $
where
dir = "/var/log/journal"
--- | Defines a container with a given machine name, containing the specified
--- System. Properties can be added to configure the Container.
+-- | Defines a container with a given machine name.
--
--- > container "webserver" (System (Debian Unstable) "amd64")
+-- Properties can be added to configure the Container.
+--
+-- > container "webserver" (Chroot.debootstrapped (System (Debian Unstable) "amd64") mempty)
-- > & Apt.installedRunning "apache2"
-- > & ...
-container :: MachineName -> System -> Container
-container name system = Container name system (Host name [] mempty)
+container :: MachineName -> (FilePath -> Chroot.Chroot) -> Container
+container name mkchroot = Container name c h
& os system
+ where
+ c@(Chroot.Chroot _ system _ _) = mkchroot (containerDir name)
+ h = Host name [] mempty
-- | Runs a container using systemd-nspawn.
--
@@ -93,7 +97,8 @@ container name system = Container name system (Host name [] mempty)
-- Reverting this property stops the container, removes the systemd unit,
-- and deletes the chroot and all its contents.
nspawned :: Container -> RevertableProperty
-nspawned c@(Container name system h) = RevertableProperty setup teardown
+nspawned c@(Container name (Chroot.Chroot loc system builderconf _) h) =
+ RevertableProperty setup teardown
where
setup = combineProperties ("nspawned " ++ name) $
map toProp steps ++ [containerprovisioned]
@@ -117,7 +122,7 @@ nspawned c@(Container name system h) = RevertableProperty setup teardown
containerprovisioned = Chroot.propellChroot chroot
(enterContainerProcess c)
- mkChroot = Chroot.Chroot (containerDir name) system
+ mkChroot = Chroot.Chroot loc system builderconf
chroot = mkChroot h
nspawnService :: Container -> RevertableProperty