summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoey Hess2014-11-21 14:31:13 -0400
committerJoey Hess2014-11-21 14:31:13 -0400
commit36e89cd148cd266254f4c50c5396d05433ed9bb3 (patch)
tree1deef27538cb26860a96f794ca7d810c9c7f430f
parentcf3a8883ecec79ad8b44be956ae98db3bfa3f42f (diff)
os info propigation
Also, lost the systemd-nspawn parameters; I'll do that some other way.
-rw-r--r--config-joey.hs3
-rw-r--r--src/Propellor/Property/Chroot.hs2
-rw-r--r--src/Propellor/Property/Systemd.hs28
3 files changed, 18 insertions, 15 deletions
diff --git a/config-joey.hs b/config-joey.hs
index da7d8ea7..a12544df 100644
--- a/config-joey.hs
+++ b/config-joey.hs
@@ -86,8 +86,9 @@ clam = standardSystem "clam.kitenet.net" Unstable "amd64"
& Systemd.nspawned meow
meow :: Systemd.Container
-meow = Systemd.container "meow" (System (Debian Unstable) "amd64") []
+meow = Systemd.container "meow" (System (Debian Unstable) "amd64")
& Apt.serviceInstalledRunning "uptimed"
+ & alias "meow.kitenet.net"
testChroot :: Chroot.Chroot
testChroot = Chroot.chroot "/tmp/chroot" (System (Debian Unstable) "amd64")
diff --git a/src/Propellor/Property/Chroot.hs b/src/Propellor/Property/Chroot.hs
index 7fee3a59..2aad26f3 100644
--- a/src/Propellor/Property/Chroot.hs
+++ b/src/Propellor/Property/Chroot.hs
@@ -19,6 +19,7 @@ import Data.List.Utils
import System.Posix.Directory
data Chroot = Chroot FilePath System Host
+ deriving (Show)
instance Hostlike Chroot where
(Chroot l s h) & p = Chroot l s (h & p)
@@ -33,6 +34,7 @@ instance Hostlike Chroot where
-- > & ...
chroot :: FilePath -> System -> Chroot
chroot location system = Chroot location system (Host location [] mempty)
+ & os system
-- | Ensures that the chroot exists and is provisioned according to its
-- properties.
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