summaryrefslogtreecommitdiff
path: root/src/Propellor/Property/Systemd.hs
diff options
context:
space:
mode:
authorJoey Hess2014-11-21 14:31:13 -0400
committerJoey Hess2014-11-21 14:31:13 -0400
commit36e89cd148cd266254f4c50c5396d05433ed9bb3 (patch)
tree1deef27538cb26860a96f794ca7d810c9c7f430f /src/Propellor/Property/Systemd.hs
parentcf3a8883ecec79ad8b44be956ae98db3bfa3f42f (diff)
os info propigation
Also, lost the systemd-nspawn parameters; I'll do that some other way.
Diffstat (limited to 'src/Propellor/Property/Systemd.hs')
-rw-r--r--src/Propellor/Property/Systemd.hs28
1 files changed, 14 insertions, 14 deletions
diff --git a/src/Propellor/Property/Systemd.hs b/src/Propellor/Property/Systemd.hs
index 9b0a445d..c6f57e23 100644
--- a/src/Propellor/Property/Systemd.hs
+++ b/src/Propellor/Property/Systemd.hs
@@ -22,14 +22,12 @@ type ServiceName = String
type MachineName = String
-type NspawnParam = CommandParam
-
-data Container = Container MachineName System [CommandParam] Host
+data Container = Container MachineName System Host
instance Hostlike Container where
- (Container n s ps h) & p = Container n s ps (h & p)
- (Container n s ps h) &^ p = Container n s ps (h &^ p)
- getHost (Container _ _ _ h) = h
+ (Container n s h) & p = Container n s (h & p)
+ (Container n s h) &^ p = Container n s (h &^ p)
+ getHost (Container _ _ h) = h
-- dbus is only a Recommends of systemd, but is needed for communication
-- from the systemd inside a container to the one outside, so make sure it
@@ -67,9 +65,12 @@ persistentJournal = check (not <$> doesDirectoryExist dir) $
-- | Defines a container with a given machine name, containing the specified
-- System. Properties can be added to configure the Container.
--
--- > container "webserver" (System (Debian Unstable) "amd64") []
-container :: MachineName -> System -> [NspawnParam] -> Container
-container name system ps = Container name system ps (Host name [] mempty)
+-- > container "webserver" (System (Debian Unstable) "amd64")
+-- > & Apt.installedRunning "apache2"
+-- > & ...
+container :: MachineName -> System -> Container
+container name system = Container name system (Host name [] mempty)
+ & os system
-- | Runs a container using systemd-nspawn.
--
@@ -86,7 +87,7 @@ container name system ps = Container name system ps (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 system h) = RevertableProperty setup teardown
where
setup = combineProperties ("nspawned " ++ name) $
map toProp steps ++ [containerprovisioned]
@@ -114,7 +115,7 @@ nspawned c@(Container name system _ h) = RevertableProperty setup teardown
chroot = mkChroot h
nspawnService :: Container -> RevertableProperty
-nspawnService (Container name _ ps _) = RevertableProperty setup teardown
+nspawnService (Container name _ _) = RevertableProperty setup teardown
where
service = nspawnServiceName name
servicefile = "/etc/systemd/system/multi-user.target.wants" </> service
@@ -122,7 +123,6 @@ nspawnService (Container name _ ps _) = RevertableProperty setup teardown
setup = check (not <$> doesFileExist servicefile) $
started service
`requires` enabled service
- -- TODO ^ adjust execStart line to reflect ps
teardown = undefined
@@ -132,7 +132,7 @@ nspawnService (Container name _ ps _) = RevertableProperty setup teardown
-- This uses nsenter to enter the container, by looking up the pid of the
-- container's init process and using its namespace.
enterScript :: Container -> RevertableProperty
-enterScript c@(Container name _ _ _) = RevertableProperty setup teardown
+enterScript c@(Container name _ _) = RevertableProperty setup teardown
where
setup = combineProperties ("generated " ++ enterScriptFile c)
[ scriptfile `File.hasContent`
@@ -152,7 +152,7 @@ enterScript c@(Container name _ _ _) = RevertableProperty setup teardown
scriptfile = enterScriptFile c
enterScriptFile :: Container -> FilePath
-enterScriptFile (Container name _ _ _ ) = "/usr/local/bin/enter-" ++ mungename name
+enterScriptFile (Container name _ _ ) = "/usr/local/bin/enter-" ++ mungename name
enterContainerProcess :: Container -> [String] -> CreateProcess
enterContainerProcess = proc . enterScriptFile