diff --git a/salt/modules/nspawn.py b/salt/modules/nspawn.py index 76874daa25..ef58f2aae6 100644 --- a/salt/modules/nspawn.py +++ b/salt/modules/nspawn.py @@ -6,36 +6,21 @@ import os import shutil # Import Salt libs import salt.defaults.exitcodes +import salt.utils.systemd __virtualname__ = 'nspawn' +WANT = '/etc/systemd/system/multi-user.target.wants/systemd-nspawn@{0}.service' def __virtual__(): ''' Only work on systems that have been booted with systemd ''' - if __grains__['kernel'] == 'Linux' and _sd_booted(__context__): + if __grains__['kernel'] == 'Linux' and salt.utils.systemd.booted(__context__): return __virtualname__ return False -def _sd_booted(context): - ''' - Return True if the system was booted with systemd, False otherwise. - ''' - # We can cache this for as long as the minion runs. - if "systemd.sd_booted" not in context: - try: - # This check does the same as sd_booted() from libsystemd-daemon: - # http://www.freedesktop.org/software/systemd/man/sd_booted.html - if os.stat('/run/systemd/system'): - context['systemd.sd_booted'] = True - except OSError: - context['systemd.sd_booted'] = False - - return context['systemd.sd_booted'] - - def _arch_bootstrap(name, **kwargs): ''' Bootstrap an Arch Linux container