summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--debian/changelog9
-rw-r--r--src/Propellor/Property/Systemd.hs62
2 files changed, 33 insertions, 38 deletions
diff --git a/debian/changelog b/debian/changelog
index 6bfaa70d..e5eacd30 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,12 @@
+propellor (4.6.2) UNRELEASED; urgency=medium
+
+ * Systemd.nspawned: Recent systemd versions such as 234 ignore
+ non-symlinks in /etc/systemd/system/multi-user.target.wants,
+ which was used to configure systemd-nspawn parameters. Instead,
+ use a service.d/local.conf file to configure that.
+
+ -- Joey Hess <id@joeyh.name> Thu, 27 Jul 2017 16:34:37 -0400
+
propellor (4.6.1) unstable; urgency=medium
* Added Network.dhcp' and Network.static', which allow specifying
diff --git a/src/Propellor/Property/Systemd.hs b/src/Propellor/Property/Systemd.hs
index d1a94aa8..473b2f39 100644
--- a/src/Propellor/Property/Systemd.hs
+++ b/src/Propellor/Property/Systemd.hs
@@ -283,54 +283,40 @@ nspawned c@(Container name (Chroot.Chroot loc builder _ _) h) =
chroot = Chroot.Chroot loc builder Chroot.propagateChrootInfo h
--- | Sets up the service file for the container, and then starts
--- it running.
+-- | Sets up the service files for the container, using the
+-- systemd-nspawn@.service template, and starts it running.
nspawnService :: Container -> ChrootCfg -> RevertableProperty Linux Linux
nspawnService (Container name _ _) cfg = setup <!> teardown
where
service = nspawnServiceName name
- servicefile = "/etc/systemd/system/multi-user.target.wants" </> service
-
- servicefilecontent = do
- ls <- lines <$> readFile "/lib/systemd/system/systemd-nspawn@.service"
- return $ unlines $
- "# deployed by propellor" : map addparams ls
- addparams l
- | "ExecStart=" `isPrefixOf` l = unwords $
- [ "ExecStart = /usr/bin/systemd-nspawn"
- , "--quiet"
- , "--keep-unit"
- , "--boot"
- , "--directory=" ++ containerDir name
- , "--machine=%i"
- ] ++ nspawnServiceParams cfg
- | otherwise = l
-
- goodservicefile = (==)
- <$> servicefilecontent
- <*> catchDefaultIO "" (readFile servicefile)
-
- writeservicefile :: Property Linux
- writeservicefile = property servicefile $ makeChange $ do
- c <- servicefilecontent
- File.viaStableTmp (\t -> writeFile t c) servicefile
-
- setupservicefile :: Property Linux
- setupservicefile = check (not <$> goodservicefile) $
- -- if it's running, it has the wrong configuration,
- -- so stop it
- stopped service
- `requires` daemonReloaded
- `requires` writeservicefile
+ overridedir = "/etc/systemd/system" </> nspawnServiceName name ++ ".d"
+ overridefile = overridedir </> "local.conf"
+ overridecontent =
+ [ "[Service]"
+ , "ExecStart=/usr/bin/systemd-nspawn " ++ unwords nspawnparams
+ ]
+ nspawnparams =
+ [ "--quiet"
+ , "--keep-unit"
+ , "--boot"
+ , "--directory=" ++ containerDir name
+ , "--machine=" ++ name
+ ] ++ nspawnServiceParams cfg
+
+ overrideconfigured = File.hasContent overridefile overridecontent
+ `onChange` daemonReloaded
+ `requires` File.dirExists overridedir
setup :: Property Linux
setup = started service
- `requires` setupservicefile
+ `requires` enabled service
+ `requires` overrideconfigured
`requires` machined
teardown :: Property Linux
- teardown = check (doesFileExist servicefile) $
- disabled service `requires` stopped service
+ teardown = stopped service
+ `before` disabled service
+ `before` File.notPresent overridefile
nspawnServiceParams :: ChrootCfg -> [String]
nspawnServiceParams NoChrootCfg = []