code: def list_all():
      '''
      Lists all nspawn containers
  
      CLI Example:
  
      .. code-block:: bash
  
          salt myminion nspawn.list_all
      '''
      ret = []
      if _sd_version() >= 219:
          for line in _machinectl('list-images')['stdout'].splitlines():
              try:
                  ret.append(line.split()[0])
              except IndexError:
                  continue
      else:
          rootdir = _root()
          try:
              for dirname in os.listdir(rootdir):
                  if os.path.isdir(os.path.join(rootdir, dirname)):
                      ret.append(dirname)
          except OSError:
              pass
      return ref list_all():
      '''
      Lists all nspawn containers
  
      CLI Example:
  
      .. code-block:: bash
  
          salt myminion nspawn.list_all
      '''
      ret = []
      if _sd_version() >= 219:
          for line in _machinectl('list-images')['stdout'].splitlines():
              try:
                  ret.append(line.split()[0])
              except IndexError:
                  continue
      else:
          rootdir = _root()
          try:
              for dirname in os.listdir(rootdir):
                  if os.path.isdir(os.path.join(rootdir, dirname)):
                      ret.append(dirname)
          except OSError:
              pass
      return ret
docs: Lists all nspawn containers
  
      CLI Example:
  
      .. code-block:: bash
  
          salt myminion nspawn.list_all